mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-07-10 10:51:00 +02:00
Remove usePagePath
This commit is contained in:
parent
26e0b4390b
commit
40ca67c8c6
@ -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<Options>) => {
|
||||
// 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<Options>) => {
|
||||
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<Options>) => {
|
||||
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"
|
||||
|
@ -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))
|
||||
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user