modify contentPage rather than new plugin

This commit is contained in:
josh-sanders 2025-03-17 20:54:04 +10:00
parent d14dd4e56c
commit c1182108db
3 changed files with 21 additions and 6 deletions

View File

@ -135,6 +135,6 @@ 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]].
To enable easy customization, the `homePage` emitter allows you to fully rearrange the layout of the home page. The default home page layout is called `defaultHomePageLayout{:ts}` and can be found in `quartz.layout.ts`. The layout of the home page and all other content pages is the same by default. See [[layout|the layout documentation]] for further guidance.
To enable easy customization, Quartz allows you to fully rearrange the layout of the home page. The default home page layout is called `defaultHomePageLayout{:ts}` and can be found in `quartz.layout.ts`. The layout of the home page is the same as all other content pages by default. See [[layout|the layout documentation]] for further guidance on changing the layout.
A differnet method is used to configure the comment box on the home page, see [[Comments#Conditionally display comments|conditionally display comments]].
A different method is used to configure the comment box on the home page, see [[Comments#Conditionally display comments|conditionally display comments]].

View File

@ -67,7 +67,7 @@ export const defaultListPageLayout: PageLayout = {
export const defaultHomePageLayout: HomePageLayout = {
...sharedPageComponents,
...defaultContentPageLayout,
// head: Component.Head(),
// head: Component.Head(),
// header: [],
// left: [],
// beforeBody: [],

View File

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