mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 13:24:05 -06:00
Add 'hideOnRoot' option to Component.Explorer
This commit is contained in:
parent
1df9e9564f
commit
e02b080fd1
@ -135,10 +135,11 @@ typography: {
|
|||||||
|
|
||||||
The home page is the main web page of your Quartz. The content for the home page lives in `content/index.md`, to change it see [[authoring content|the authoring content guide]].
|
The home page is the main web page of your Quartz. The content for the home page lives in `content/index.md`, to change it see [[authoring content|the authoring content guide]].
|
||||||
|
|
||||||
Customization of the home page can be achieved by conditionally hiding or unhiding components; by passing in a boolean value to the `hideOnRoot:` options in `quartz.config.ts`. The components that support this feature are:
|
Customization of the home page can be achieved by conditionally hiding or unhiding components; by passing in a boolean value to the `hideOnRoot{:ts}` option for the components detailed in the `defaultContentPageLayout{:ts}` variable in `quartz.config.ts`. The components that support this feature are:
|
||||||
|
|
||||||
- [[Backlinks]] are shown by default, to hide them the configuration looks like: `Component.Backlinks({ hideOnRoot: true }){:ts}`
|
- [[Backlinks]] are shown by default, to hide them the configuration looks like: `Component.Backlinks({ hideOnRoot: true }){:ts}`
|
||||||
- [[Breadcrumbs]] are hidden by default, to unhide them the configuration looks like: `Component.Breadcrumbs({ hideOnRoot: false }){:ts}`
|
- [[Breadcrumbs]] are hidden by default, to unhide them the configuration looks like: `Component.Breadcrumbs({ hideOnRoot: false }){:ts}`
|
||||||
- Date and reading time are shown by default, to hide them the configuration looks like: `Component.ContentMeta({ hideOnRoot: true }){:ts}`
|
- Date and reading time are shown by default, to hide them the configuration looks like: `Component.ContentMeta({ hideOnRoot: true }){:ts}`
|
||||||
|
- [[Explorer]] is shown by default, to hide it the configuration looks like: `Component.Explorer({ hideOnRoot: true }){:ts}`
|
||||||
|
|
||||||
A differnet method is used to configure the comment box on the home page, see [[Comments#Conditionally display comments|conditionally display comments]].
|
A differnet method is used to configure the comment box on the home page, see [[Comments#Conditionally display comments|conditionally display comments]].
|
||||||
|
|||||||
@ -42,6 +42,7 @@ Want to customize it even more?
|
|||||||
|
|
||||||
- Removing explorer: remove `Component.Explorer()` from `quartz.layout.ts`
|
- Removing explorer: remove `Component.Explorer()` from `quartz.layout.ts`
|
||||||
- (optional): After removing the explorer component, you can move the [[table of contents | Table of Contents]] component back to the `left` part of the layout
|
- (optional): After removing the explorer component, you can move the [[table of contents | Table of Contents]] component back to the `left` part of the layout
|
||||||
|
- Hide on root: hide `Explorer` on the home page `content/index.md` (default to `false`). To enable this, use `Component.Explorer({ hideOnRoot: true })`.
|
||||||
- Changing `sort`, `filter` and `map` behavior: explained in [[#Advanced customization]]
|
- Changing `sort`, `filter` and `map` behavior: explained in [[#Advanced customization]]
|
||||||
- Component:
|
- Component:
|
||||||
- Wrapper (Outer component, generates file tree, etc): `quartz/components/Explorer.tsx`
|
- Wrapper (Outer component, generates file tree, etc): `quartz/components/Explorer.tsx`
|
||||||
|
|||||||
@ -20,6 +20,7 @@ export interface Options {
|
|||||||
filterFn: (node: FileTrieNode) => boolean
|
filterFn: (node: FileTrieNode) => boolean
|
||||||
mapFn: (node: FileTrieNode) => void
|
mapFn: (node: FileTrieNode) => void
|
||||||
order: OrderEntries[]
|
order: OrderEntries[]
|
||||||
|
hideOnRoot: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: Options = {
|
const defaultOptions: Options = {
|
||||||
@ -48,6 +49,7 @@ const defaultOptions: Options = {
|
|||||||
},
|
},
|
||||||
filterFn: (node) => node.slugSegment !== "tags",
|
filterFn: (node) => node.slugSegment !== "tags",
|
||||||
order: ["filter", "map", "sort"],
|
order: ["filter", "map", "sort"],
|
||||||
|
hideOnRoot: false
|
||||||
}
|
}
|
||||||
|
|
||||||
export type FolderState = {
|
export type FolderState = {
|
||||||
@ -59,7 +61,12 @@ export default ((userOpts?: Partial<Options>) => {
|
|||||||
const opts: Options = { ...defaultOptions, ...userOpts }
|
const opts: Options = { ...defaultOptions, ...userOpts }
|
||||||
const { OverflowList, overflowListAfterDOMLoaded } = OverflowListFactory()
|
const { OverflowList, overflowListAfterDOMLoaded } = OverflowListFactory()
|
||||||
|
|
||||||
const Explorer: QuartzComponent = ({ cfg, displayClass }: QuartzComponentProps) => {
|
const Explorer: QuartzComponent = ({ cfg, fileData, displayClass }: QuartzComponentProps) => {
|
||||||
|
// Hide explorer on root if enabled
|
||||||
|
if (opts.hideOnRoot && fileData.slug === "index") {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
class={classNames(displayClass, "explorer")}
|
class={classNames(displayClass, "explorer")}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user