2026-04-21 Post about adding notes hierarchy

This commit is contained in:
2026-04-21 16:30:45 -07:00
parent 692430f959
commit 609ac3e9c3
2 changed files with 163 additions and 2 deletions

View File

@@ -3,14 +3,14 @@ export interface HierarchyNode {
title: string | null;
children: Hierarchy | null;
}
export interface Hierarchy extends Record<string, HierarchyNode> {}
type Hierarchy = Record<string, HierarchyNode>;
function addToHierarchy(
tree: Hierarchy,
[noteId, title]: [string, string],
): Hierarchy {
const path = noteId.split("/");
if (path.length === 0) {
if (path.length === 0 || path[0] === "") {
return tree;
}