事前の思考
方法としては、quartz.layout.tsにてQuartzComponentsをいじる。
元々の機能としてComponent.RecentNotesがあるので、それを挿入すると良さそう。
(参考 https://quartz.jzhao.xyz/features/recent-notes )
本文の下に入れるならafterBodyでの定義が良さそうかな。
(参考 https://quartz.jzhao.xyz/layout )
slug === "" → トップページ(index.md)とのことなので、設定冒頭でトップページでのafterBodyの定義を行い、以下を流していくのが良さそうか。
実際のところ
Quartzのレイアウト定義は静的な配列なので、直接 slug === "" の条件分岐を書けないとのこと。
quartz/components/ にラッパーコンポーネントを作って呼び出すのが、比較的素直でメンテナンスしやすいようだ。
// quartz/components/HomeRecentNotes.tsx
import { QuartzComponent, QuartzComponentConstructor } from "./types"
import RecentNotes from "./RecentNotes"
const HomeRecentNotes: QuartzComponent = (props) => {
if (props.fileData.slug !== "index") {
return null
}
return RecentNotes({
title: "最近の更新",
limit: 5,
showTags: false,
})(props)
}
export default (() => HomeRecentNotes) satisfies QuartzComponentConstructorこれを作成した際は quartz/component/index.ts に import HomeRecentNotes from "./HomeRecentNotes"を記載し、 export の中にも HomeRecentNotes, の記載を足す必要がある。
その後、quartz.layout.ts内部のafterBody定義にて
afterBody: [ Component.HomeRecentNotes(), ],とすれば良い。