1
0
mirror of https://gitlab.com/MisterBiggs/brain-quartz.git synced 2025-07-25 07:41:30 +00:00

fix: cleanup a href link construction, global shared trie, breadcrumbs use trie

This commit is contained in:
Jacky Zhao
2025-03-23 17:24:43 -07:00
parent 457b77dd48
commit 4e74d11b1a
8 changed files with 159 additions and 96 deletions

View File

@@ -97,6 +97,24 @@ export class FileTrieNode<T extends FileTrieData = ContentDetails> {
return this.children.find((c) => c.slugSegment === path[0])?.findNode(path.slice(1))
}
ancestryChain(path: string[]): Array<FileTrieNode<T>> | undefined {
if (path.length === 0 || (path.length === 1 && path[0] === "index")) {
return [this]
}
const child = this.children.find((c) => c.slugSegment === path[0])
if (!child) {
return undefined
}
const childPath = child.ancestryChain(path.slice(1))
if (!childPath) {
return undefined
}
return [this, ...childPath]
}
/**
* Filter trie nodes. Behaves similar to `Array.prototype.filter()`, but modifies tree in place
*/