fix(folder): use memoized trie instead of handrolled path solution (closes #1767)

This commit is contained in:
Jacky Zhao committed 2025-03-14 15:08:23 -07:00
1 parent da1b6b37fe
commit fbb4523853
5 files changed
+144 -42

No files matched your search

+8
View File
@@ -89,6 +89,14 @@ export class FileTrieNode<T extends FileTrieData = ContentDetails> {
this.insert(file.slug.split("/"), file)
}
findNode(path: string[]): FileTrieNode<T> | undefined {
if (path.length === 0 || (path.length === 1 && path[0] === "index")) {
return this
}
return this.children.find((c) => c.slugSegment === path[0])?.findNode(path.slice(1))
}
/**
* Filter trie nodes. Behaves similar to `Array.prototype.filter()`, but modifies tree in place
*/