feat: add component customisation options for the index page

This commit is contained in:
Tony 2025-03-08 12:35:12 +10:30
parent a201105442
commit 5db049e856
2 changed files with 13 additions and 2 deletions

View File

@ -36,6 +36,11 @@ export const defaultContentPageLayout: PageLayout = {
], ],
} }
// components for the index page
export const indexContentPageLayout: PageLayout = {
...defaultContentPageLayout
}
// components for pages that display lists of pages (e.g. tags or folders) // components for pages that display lists of pages (e.g. tags or folders)
export const defaultListPageLayout: PageLayout = { export const defaultListPageLayout: PageLayout = {
beforeBody: [Component.Breadcrumbs(), Component.ArticleTitle(), Component.ContentMeta()], beforeBody: [Component.Breadcrumbs(), Component.ArticleTitle(), Component.ContentMeta()],

View File

@ -10,7 +10,7 @@ import { pageResources, renderPage } from "../../components/renderPage"
import { FullPageLayout } from "../../cfg" import { FullPageLayout } from "../../cfg"
import { Argv } from "../../util/ctx" import { Argv } from "../../util/ctx"
import { FilePath, isRelativeURL, joinSegments, pathToRoot } from "../../util/path" import { FilePath, isRelativeURL, joinSegments, pathToRoot } from "../../util/path"
import { defaultContentPageLayout, sharedPageComponents } from "../../../quartz.layout" import { defaultContentPageLayout, indexContentPageLayout, sharedPageComponents } from "../../../quartz.layout"
import { Content } from "../../components" import { Content } from "../../components"
import chalk from "chalk" import chalk from "chalk"
import { write } from "./helpers" import { write } from "./helpers"
@ -52,7 +52,7 @@ const parseDependencies = (argv: Argv, hast: Root, file: VFile): string[] => {
} }
export const ContentPage: QuartzEmitterPlugin<Partial<FullPageLayout>> = (userOpts) => { export const ContentPage: QuartzEmitterPlugin<Partial<FullPageLayout>> = (userOpts) => {
const opts: FullPageLayout = { let opts: FullPageLayout = {
...sharedPageComponents, ...sharedPageComponents,
...defaultContentPageLayout, ...defaultContentPageLayout,
pageBody: Content(), pageBody: Content(),
@ -104,6 +104,12 @@ export const ContentPage: QuartzEmitterPlugin<Partial<FullPageLayout>> = (userOp
const slug = file.data.slug! const slug = file.data.slug!
if (slug === "index") { if (slug === "index") {
containsIndex = true containsIndex = true
opts = {
...sharedPageComponents,
...indexContentPageLayout,
pageBody: Content(),
...userOpts,
}
} }
const externalResources = pageResources(pathToRoot(slug), file.data, resources) const externalResources = pageResources(pathToRoot(slug), file.data, resources)