Quartz 是一款原生支持 Obsidian 的网站生成工具,可以将 Markdown 内容转换成对应的页面。为了方便管理,我将内容拆分成了两部分,分别存放在两个仓库中:
首先根据自己的需求,对配置文件(quartz.config.ts 和 quartz.layout.ts)进行更改
// components for pages that display a single page (e.g. a single note)
export const defaultContentPageLayout: PageLayout = {
beforeBody: [
Component.ConditionalRender({
component: Component.Breadcrumbs(),
condition: (page) => page.fileData.slug !== "index",
}),
Component.ArticleTitle(),
Component.ContentMeta(),
Component.TagList(),
],
left: [
Component.PageTitle(),
Component.MobileOnly(Component.Spacer()),
Component.Flex({
components: [
{
Component: Component.Search(),
grow: true,
},
{ Component: Component.Darkmode() },
{ Component: Component.ReaderMode() },
],
}),
Component.DesktopOnly(Component.RecentNotes({
limit: 3,
})),
],
right: [
Component.Graph(),
Component.DesktopOnly(Component.TableOfContents()),
Component.Backlinks(),
],
}
// components for pages that display lists of pages (e.g. tags or folders)
export const defaultListPageLayout: PageLayout = {
beforeBody: [Component.Breadcrumbs(), Component.ArticleTitle(), Component.ContentMeta()],
left: [
Component.PageTitle(),
Component.MobileOnly(Component.Spacer()),
Component.Flex({
components: [
{
Component: Component.Search(),
grow: true,
},
{ Component: Component.Darkmode() },
],
})
],
right: [],
}删除原来 content 目录,并提交修改
git rm -r content
添加子模块,⚠️替换成 SSH 格式的仓库链接(假设仓库名称就叫 notes),并提交修改
git submodule add [email protected]:<your username>/<your repo name>.git content
后续通过 Obsidian 对存放文档仓库进行编辑即可,为了确保每次对 notes 仓库的修改可以自动同步到你的 Quartz 仓库对应的 submodule,创建如下 action 并提交修改。
Info
需要创建对应的 PAT,并赋予上面提及的两个仓库
Contents读写权限,并添加至secrets
name: Update submodule link
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "sync"
cancel-in-progress: false
jobs:
update-quartz:
runs-on: ubuntu-latest
steps:
- name: Checkout personal access token
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner }}/quartz
submodules: recursive
token: ${{ secrets.PAT }}
- name: Update Submodules
uses: sgoudham/[email protected]
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v5
使用 Cloudflare Page 进行构建,选择导入现有 Git 仓库,勾选上面提及的两个仓库并允许 Cloudflare 访问。配置如下:
- 构建命令:
git submodule init && git submodule update && npx quartz build - 输出目录:
public