The quartzCustomizations directory exports explorerConfig, and object to configure Quartz’s native Explorer component. These customizations are:
- Add a custom
sortFn. With this function, all pages with aorderfrontmatter property, are sorted by that property’s value. Pages without anorderfrontmatter property are then sorted afterwards. - Set
folderClickBehaviorto ‘link’ - Add a custom
filterFn. With this function directories named ‘data’ (this is matched ignoring case) are excluded from the Explorer sidebar tree. This does not cause Quartz to ignore these pages — they are still rendered to html and accessible via interlinks between pages. They just will not show up in the Explorer tree view.
Further explanation of these changes can be found in the Quartz Explorer documentation
Enabling the updated Explorer configuration
- Restore Frontmatter to the sortFn arguments (see below)
- Open
quartz.layout.ts - Import
explorerConfigfrom thequartzCustomizationsfile - Replace any calls of
Component.Explorer()withComponent.Explorer(explorerConfig). There should be two: one in the content page layout and one in the list page layout.
Restoring Frontmatter
Note: A recent update to quartz removed frontmatter from the object that is passed to sortFn for sorting. Restoring it requires editing core quartz files. See: https://draftz.felixnie.com/Digital-Garden/Sorting-Objects-in-Explorer#add-frontmatter-back
Example Implementation
// quartz.layout.ts
...
import { explorerConfig } from "../quartzCustomizations"
// components for pages that display a single page (e.g. a single note)
export const defaultContentPageLayout: PageLayout = {
beforeBody: [...],
left: [
...
// Replace:
// Component.DesktopOnly(Component.Explorer()),
// with:
Component.DesktopOnly(Component.Explorer(explorerConfig)),
],
right: [...]
}
// components for pages that display lists of pages (e.g. tags or folders)
export const defaultListPageLayout: PageLayout = {
beforeBody: [...],
left: [
...
// Replace:
// Component.DesktopOnly(Component.Explorer()),
// with:
Component.DesktopOnly(Component.Explorer(explorerConfig)),
],
right: [],
}
...