Note
This is part of the Advanced Customizations.
In Quartz, thereās a global configuration for default collapse status of folders. In case we want to highlight the key sections of the site, while keeping others initially folded, we can use a collapsed
attribute in the frontmatter of index.md
.
In the following snippet, if thereās no previous state, Quartz will turn to read the config from the frontmatter. The global configuration will apply when thereās no available entry in frontmatter.
// Get folder paths for state management
const folderPaths = trie.getFolderPaths()
currentExplorerState = folderPaths.map((path) => {
const previousState = oldIndex.get(path)
// mod: while initializing, use frontmatter state first if available
const folderNode = trie.findNode(path.split("/"))
const folderNodeState = folderNode?.data?.frontmatter?.collapsed === 'true'
const defaultState = opts.folderDefaultState === "collapsed"
return {
path,
collapsed:
previousState ??
folderNodeState ??
defaultState,
}
})