From fbb452385325d4418ce53e61178fe2494255caf5 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Fri, 14 Mar 2025 22:08:23 +0000
Subject: [PATCH] fix(folder): use memoized trie instead of handrolled path solution (closes #1767)

---
 quartz/util/fileTrie.ts |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/quartz/util/fileTrie.ts b/quartz/util/fileTrie.ts
index b39833c..e3dc2e7 100644
--- a/quartz/util/fileTrie.ts
+++ b/quartz/util/fileTrie.ts
@@ -89,6 +89,14 @@
     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
    */

--
Gitblit v1.10.0