mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 13:24:05 -06:00
Add hideOnRoot option to Component.ContentMeta
This commit is contained in:
parent
c005fe4408
commit
fac62575ae
@ -130,3 +130,14 @@ typography: {
|
|||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Home Page
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
- [[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}`
|
||||||
|
|
||||||
|
A differnet method is used to configure the comment box on the home page, see [[Comments#Conditionally display comments|conditionally display comments]].
|
||||||
|
|||||||
@ -12,11 +12,13 @@ interface ContentMetaOptions {
|
|||||||
*/
|
*/
|
||||||
showReadingTime: boolean
|
showReadingTime: boolean
|
||||||
showComma: boolean
|
showComma: boolean
|
||||||
|
hideOnRoot: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: ContentMetaOptions = {
|
const defaultOptions: ContentMetaOptions = {
|
||||||
showReadingTime: true,
|
showReadingTime: true,
|
||||||
showComma: true,
|
showComma: true,
|
||||||
|
hideOnRoot: false
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ((opts?: Partial<ContentMetaOptions>) => {
|
export default ((opts?: Partial<ContentMetaOptions>) => {
|
||||||
@ -24,6 +26,11 @@ export default ((opts?: Partial<ContentMetaOptions>) => {
|
|||||||
const options: ContentMetaOptions = { ...defaultOptions, ...opts }
|
const options: ContentMetaOptions = { ...defaultOptions, ...opts }
|
||||||
|
|
||||||
function ContentMetadata({ cfg, fileData, displayClass }: QuartzComponentProps) {
|
function ContentMetadata({ cfg, fileData, displayClass }: QuartzComponentProps) {
|
||||||
|
// Hide metadata on root if enabled
|
||||||
|
if (options.hideOnRoot && fileData.slug === "index") {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
const text = fileData.text
|
const text = fileData.text
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user