diff --git a/docs/configuration.md b/docs/configuration.md index d0eed006a..e53725f47 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -137,6 +137,7 @@ The home page is the main web page of your Quartz. The content for the home page 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: +- [[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}` - Date and reading time are shown by default, to hide them the configuration looks like: `Component.ContentMeta({ hideOnRoot: true }){:ts}` diff --git a/docs/features/backlinks.md b/docs/features/backlinks.md index 6862720e1..35e5d425d 100644 --- a/docs/features/backlinks.md +++ b/docs/features/backlinks.md @@ -10,6 +10,7 @@ A backlink for a note is a link from another note to that note. Links in the bac - Removing backlinks: delete all usages of `Component.Backlinks()` from `quartz.layout.ts`. - Hide when empty: hide `Backlinks` if given page doesn't contain any backlinks (default to `true`). To disable this, use `Component.Backlinks({ hideWhenEmpty: false })`. +- Hide on root: hide `Backlinks` on the home page `content/index.md` (default to `false`). To enable this, use `Component.Backlinks({ hideOnRoot: true })`. - Component: `quartz/components/Backlinks.tsx` - Style: `quartz/components/styles/backlinks.scss` - Script: `quartz/components/scripts/search.inline.ts` diff --git a/quartz/components/Backlinks.tsx b/quartz/components/Backlinks.tsx index 0d34457f3..a630e4114 100644 --- a/quartz/components/Backlinks.tsx +++ b/quartz/components/Backlinks.tsx @@ -7,10 +7,12 @@ import OverflowListFactory from "./OverflowList" interface BacklinksOptions { hideWhenEmpty: boolean + hideOnRoot: boolean } const defaultOptions: BacklinksOptions = { hideWhenEmpty: true, + hideOnRoot: false } export default ((opts?: Partial) => { @@ -23,6 +25,11 @@ export default ((opts?: Partial) => { displayClass, cfg, }: QuartzComponentProps) => { + // Hide backlinks on root if enabled + if (options.hideOnRoot && fileData.slug === "index") { + return null + } + const slug = simplifySlug(fileData.slug!) const backlinkFiles = allFiles.filter((file) => file.links?.includes(slug)) if (options.hideWhenEmpty && backlinkFiles.length == 0) {