From 40ca67c8c6f46600bb571ba942b2689bd44b02cd Mon Sep 17 00:00:00 2001 From: saberzero1 Date: Thu, 3 Oct 2024 22:13:46 +0200 Subject: [PATCH] Remove usePagePath --- quartz/components/Explorer.tsx | 6 +----- quartz/components/ExplorerNode.tsx | 9 ++------- quartz/components/scripts/explorer.inline.ts | 3 +-- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/quartz/components/Explorer.tsx b/quartz/components/Explorer.tsx index d5c34dd2a..4c8eba654 100644 --- a/quartz/components/Explorer.tsx +++ b/quartz/components/Explorer.tsx @@ -13,7 +13,6 @@ const defaultOptions = { folderClickBehavior: "collapse", folderDefaultState: "collapsed", useSavedState: true, - usePagePath: false, mapFn: (node) => { return node }, @@ -70,8 +69,7 @@ export default ((userOpts?: Partial) => { // Get all folders of tree. Initialize with collapsed state // Stringify to pass json tree as data attribute ([data-tree]) const folders = fileTree.getFolderPaths( - opts.folderDefaultState === "collapsed", - currentFilePath, + opts.folderDefaultState === "collapsed" ) jsonTree = JSON.stringify(folders) } @@ -97,7 +95,6 @@ export default ((userOpts?: Partial) => { data-behavior={opts.folderClickBehavior} data-collapsed={opts.folderDefaultState} data-savestate={opts.useSavedState} - data-pagepathstate={opts.usePagePath} data-tree={jsonTree} data-mobile={true} aria-controls="explorer-content" @@ -125,7 +122,6 @@ export default ((userOpts?: Partial) => { data-behavior={opts.folderClickBehavior} data-collapsed={opts.folderDefaultState} data-savestate={opts.useSavedState} - data-pagepathstate={opts.usePagePath} data-tree={jsonTree} data-mobile={false} aria-controls="explorer-content" diff --git a/quartz/components/ExplorerNode.tsx b/quartz/components/ExplorerNode.tsx index 9b3080fc1..e57d67715 100644 --- a/quartz/components/ExplorerNode.tsx +++ b/quartz/components/ExplorerNode.tsx @@ -16,7 +16,6 @@ export interface Options { folderDefaultState: "collapsed" | "open" folderClickBehavior: "collapse" | "link" useSavedState: boolean - usePagePath: boolean sortFn: (a: FileNode, b: FileNode) => number filterFn: (node: FileNode) => boolean mapFn: (node: FileNode) => void @@ -125,20 +124,16 @@ export class FileNode { * Get folder representation with state of tree. * Intended to only be called on root node before changes to the tree are made * @param collapsed default state of folders (collapsed by default or not) - * @param currentFile current file * @returns array containing folder state for tree */ - getFolderPaths(collapsed: boolean, currentFile: string): FolderState[] { + getFolderPaths(collapsed: boolean): FolderState[] { const folderPaths: FolderState[] = [] const traverse = (node: FileNode, currentPath: string) => { if (!node.file) { const folderPath = joinSegments(currentPath, node.name) - const collapseState = !currentFile.includes( - folderPath.replace("'", "-").replaceAll("../", ""), - ) if (folderPath !== "") { - folderPaths.push({ path: folderPath, collapsed: collapseState || collapsed }) + folderPaths.push({ path: folderPath, collapsed }) } node.children.forEach((child) => traverse(child, folderPath)) diff --git a/quartz/components/scripts/explorer.inline.ts b/quartz/components/scripts/explorer.inline.ts index 11703b33c..a59224d0e 100644 --- a/quartz/components/scripts/explorer.inline.ts +++ b/quartz/components/scripts/explorer.inline.ts @@ -88,7 +88,6 @@ function setupExplorer() { // Convert to bool const useSavedFolderState = explorer?.dataset.savestate === "true" - const usePagePathState = explorer?.dataset.pagepathstate === "true" if (explorer) { // Get config @@ -129,7 +128,7 @@ function setupExplorer() { for (const { path, collapsed } of newExplorerState) { currentExplorerState.push({ path, - collapsed: usePagePathState ? (oldIndex.get(path) ?? collapsed) : collapsed, + collapsed: oldIndex.get(path) ?? collapsed, }) }