| | |
| | | // memoized |
| | | let fileTree: FileNode |
| | | let jsonTree: string |
| | | let lastBuildId: string = "" |
| | | |
| | | function constructFileTree(allFiles: QuartzPluginData[]) { |
| | | if (fileTree) { |
| | | return |
| | | } |
| | | |
| | | // Construct tree from allFiles |
| | | fileTree = new FileNode("") |
| | | allFiles.forEach((file) => fileTree.add(file)) |
| | |
| | | } |
| | | |
| | | const Explorer: QuartzComponent = ({ |
| | | ctx, |
| | | cfg, |
| | | allFiles, |
| | | displayClass, |
| | | fileData, |
| | | }: QuartzComponentProps) => { |
| | | constructFileTree(allFiles) |
| | | if (ctx.buildId !== lastBuildId) { |
| | | lastBuildId = ctx.buildId |
| | | constructFileTree(allFiles) |
| | | } |
| | | |
| | | return ( |
| | | <div class={classNames(displayClass, "explorer")}> |
| | | <button |
| | |
| | | data-collapsed={opts.folderDefaultState} |
| | | data-savestate={opts.useSavedState} |
| | | data-tree={jsonTree} |
| | | aria-controls="explorer-content" |
| | | aria-expanded={opts.folderDefaultState === "open"} |
| | | > |
| | | <h2>{opts.title ?? i18n(cfg.locale).components.explorer.title}</h2> |
| | | <svg |