diff --git a/quartz/components/Explorer.tsx b/quartz/components/Explorer.tsx index ec7c48ef7..df876ab61 100644 --- a/quartz/components/Explorer.tsx +++ b/quartz/components/Explorer.tsx @@ -7,6 +7,7 @@ import { ExplorerNode, FileNode, Options } from "./ExplorerNode" import { QuartzPluginData } from "../plugins/vfile" import { classNames } from "../util/lang" import { i18n } from "../i18n" +import { VNode } from "preact" // Options interface defined in `ExplorerNode` to avoid circular dependency const defaultOptions = { @@ -44,6 +45,7 @@ export default ((userOpts?: Partial) => { // memoized let fileTree: FileNode let jsonTree: string + let component: VNode let lastBuildId: string = "" function constructFileTree(allFiles: QuartzPluginData[]) { @@ -82,44 +84,46 @@ export default ((userOpts?: Partial) => { if (ctx.buildId !== lastBuildId) { lastBuildId = ctx.buildId constructFileTree(allFiles) + const tree = ExplorerNode({ node: fileTree, opts, fileData }) + component = ( +
+ +
+
    + {tree} +
  • +
+
+
+ ) } - return ( -
- -
-
    - -
  • -
-
-
- ) + return component } Explorer.css = explorerStyle diff --git a/quartz/components/ExplorerNode.tsx b/quartz/components/ExplorerNode.tsx index e57d67715..3137a3f0b 100644 --- a/quartz/components/ExplorerNode.tsx +++ b/quartz/components/ExplorerNode.tsx @@ -224,15 +224,10 @@ export function ExplorerNode({ node, opts, fullPath, fileData }: ExplorerNodePro class="content" data-folderul={folderPath} > - {node.children.map((childNode, i) => ( - - ))} + {node.children.map((childNode) => + // eagerly render children so we can memoize properly + ExplorerNode({ node: childNode, opts, fileData, fullPath: folderPath }), + )}