Obsidain 知识库发布方案
Vercel 方案
官方方案Hosting
如果子仓库是 public 的话,只需要设置下面的就好,token 都不用
## .gitmodule
[submodule "content"]
path = content
url = https://{token}@github.com/{username}/{repo}.git
如果子仓库是 praive 的话
vercel-workaround/README.md at main · vercel-contrib/vercel-workaround · GitHub
需要在 Vercel 中 Project → Settings → General ⇒ Build & Development Settings 路径设置 INSTALL COMMAND: bash ./vercel-submodule-workaround.sh && npx quartz build
并且设置环境变量 GITHUB_REPO_CLONE_TOKEN
github pages 方案
name: Deploy to GitHub Pages
on:
push:
branches:
- hugo
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.TOKEN }} #这里是添加的token,不用设置,需要在仓库中添加TOKEN,$代表的是调用刚才添加的环境变量,所以不需要设置
submodules: 'true'
- name: Checkout submodules
run: git submodule update --init --recursive
- name: config1
run: rm -rf content/.obsidian content/cedict_ts.u8 content/Extras/Templates && mv content/*.md content/Atlas && find content/ -name "*.md" | xargs -I file mv -f file content && mv content/AboutTheGarden.md content/_index.md
- name: config2
run: "ls content/ && grep -lr --null 'title' content/* | xargs -0 sed -i -E -r 's/title: "(.*)/title: \"\\1\"/g'""
- name: config3
run: rm -rf content/*.md-E
- name: Build Link Index
uses: jackyzha0/hugo-obsidian@v2.18
with:
index: true
input: content
output: assets/indices
root: .
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.96.0'
extended: true
- name: Build
run: hugo --minify --debug
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_branch: master # deploying branch
cname: www.baidu.com #修改成你的域名
子仓库提交更新父仓库
name: Send submodule updates to parent repo
on:
push:
branches:
- main
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: zhangsan/dg3 # 设置你用户名/发布仓库的仓库名,作用是将子模块更新到父仓库dg3
token: ${{ secrets.TOKEN }}
# 把子模块打开
submodules: "true"
- name: Pull & update submodules recursively
run: |
git submodule update --init --recursive
git submodule update --recursive --remote
- name: Commit
run: |
git config user.email "提交的邮箱,一般是你github的邮箱" #修改
git config user.name "你的名称" #修改
git add --all
git commit -m "Update submodules" || echo "No changes to commit"
git push讨论区
放弃了 gittalk 使用了giscus
按顺序填完将 iframe 嵌入到相关的 html 即可
踩的一些坑
- 第一行如果是
-会导致构建失败 - 目前不支持 iframe
- 标题不能有
'、"等标点符号 - gittalk 的坑
- 会有 obsidian 中
[[]]但是生成的页面中没有链接的样式,可能是框两边有空格 - Vercel在访问带有中文的链接的时候,会报 500,需要开无痕访问。这很影响博客使用!