Jacky Zhao
2025-03-24 4e74d11b1aee8c0affa0b13ba7b174d175ca3244
quartz/util/fileTrie.ts
@@ -97,6 +97,24 @@
    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
   */