Capitalize categories in hierarchy
This commit is contained in:
@@ -14,17 +14,18 @@ function addToHierarchy(
|
||||
return tree;
|
||||
}
|
||||
|
||||
if (!tree[path[0]]) {
|
||||
tree[path[0]] = { id: null, title: null, children: null };
|
||||
}
|
||||
let curr = tree[path[0]];
|
||||
// Create a dummy node to start the loop since the Hierarchy root is not a node.
|
||||
let curr: HierarchyNode = { id: null, title: null, children: tree };
|
||||
|
||||
for (const node of path) {
|
||||
// Capitalize first letter
|
||||
const nodeName = node.charAt(0).toUpperCase() + node.slice(1);
|
||||
|
||||
for (const node of path.slice(1)) {
|
||||
curr.children ||= {};
|
||||
if (!curr.children[node]) {
|
||||
curr.children[node] = { id: null, title: null, children: null };
|
||||
if (!curr.children[nodeName]) {
|
||||
curr.children[nodeName] = { id: null, title: null, children: null };
|
||||
}
|
||||
curr = curr.children[node];
|
||||
curr = curr.children[nodeName];
|
||||
}
|
||||
|
||||
curr.id = noteId;
|
||||
|
||||
Reference in New Issue
Block a user