| | |
| | | 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 = { |
| | |
| | | // memoized |
| | | let fileTree: FileNode |
| | | let jsonTree: string |
| | | let component: VNode |
| | | let lastBuildId: string = "" |
| | | |
| | | function constructFileTree(allFiles: QuartzPluginData[]) { |
| | |
| | | if (ctx.buildId !== lastBuildId) { |
| | | lastBuildId = ctx.buildId |
| | | constructFileTree(allFiles) |
| | | const tree = ExplorerNode({ node: fileTree, opts, fileData }) |
| | | component = ( |
| | | } |
| | | |
| | | return ( |
| | | <div class={classNames(displayClass, "explorer")}> |
| | | <button |
| | | type="button" |
| | |
| | | </button> |
| | | <div id="explorer-content"> |
| | | <ul class="overflow" id="explorer-ul"> |
| | | {tree} |
| | | <ExplorerNode node={fileTree} opts={opts} fileData={fileData} /> |
| | | <li id="explorer-end" /> |
| | | </ul> |
| | | </div> |
| | |
| | | ) |
| | | } |
| | | |
| | | return component |
| | | } |
| | | |
| | | Explorer.css = explorerStyle |
| | | Explorer.afterDOMLoaded = script |
| | | return Explorer |