From 94a04ab1c9fd099c808f3f4e6633722e0d13ac85 Mon Sep 17 00:00:00 2001
From: Ben Schlegel <ben5.schlegel@gmail.com>
Date: Sun, 17 Sep 2023 13:51:08 +0000
Subject: [PATCH] fix(explorer): filter function in `ExplorerNode`
---
quartz/components/ExplorerNode.tsx | 16 +++-------------
1 files changed, 3 insertions(+), 13 deletions(-)
diff --git a/quartz/components/ExplorerNode.tsx b/quartz/components/ExplorerNode.tsx
index b181744..f8b99f0 100644
--- a/quartz/components/ExplorerNode.tsx
+++ b/quartz/components/ExplorerNode.tsx
@@ -76,18 +76,8 @@
* @param filterFn function to filter tree with
*/
filter(filterFn: (node: FileNode) => boolean) {
- const filteredNodes: FileNode[] = []
-
- const traverse = (node: FileNode) => {
- if (filterFn(node)) {
- filteredNodes.push(node)
- }
- node.children.forEach(traverse)
- }
-
- traverse(this)
-
- this.children = filteredNodes
+ this.children = this.children.filter(filterFn)
+ this.children.forEach((child) => child.filter(filterFn))
}
/**
@@ -160,7 +150,7 @@
// Single file node
<li key={node.file.slug}>
<a href={resolveRelative(fileData.slug!, node.file.slug!)} data-for={node.file.slug}>
- {node.file.frontmatter?.title}
+ {node.name}
</a>
</li>
) : (
--
Gitblit v1.10.0