
































这是一篇有关如何使用 Logseq 将笔记和博客融合在一起的文章,笔记保持私有,博客保持公开。所有的笔记均保存在 Github 上,并通过 Github Action 来关联博客部署。
整体思路如下:
public 属性设置可以公开的页面;设置最小可访问 private repo 的 Github Token:
Setting -> Developer Settings -> Personal access tokens -> Tokens -> Generate new tokenExpiration 选择无期限设置,Select scopes 勾选第一个 repo 即可;Token,并配置到保存笔记的 private repo 设置:Settings -> Secrets and variables -> Actions -> New repository secretname=ACCESS_TOKEN, value=xxxx.github/workflows 目录,并添加 publish.yml 文件,内容如下:name: CI
on:
push:
branches: [main] #要生成的logseq库分支名称
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
name: Publish Logseq graph
steps:
- uses: actions/checkout@v3
- name: Logseq Publish 🚩
uses: logseq/publish-spa@v0.2.0 #生成html文件,并push到gh-pages分支
with:
theme-mode: dark
- name: add a nojekyll file #标记为非jekyll
run: touch $GITHUB_WORKSPACE/www/.nojekyll
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
repository-name: orangestara/logseq_publish # 公开的仓库地址
branch: main # The branch the action should deploy to.
folder: www # The folder the action should deploy. 临时目录名称
clean: true #始终覆盖更新
single-commit: true
trace: false
token: ${{ secrets.ACCESS_TOKEN }}新公共仓库默认没有工作流权限:
Settings --> Actions --> General,然后在工作流权限中,选择Read and write permissions
由于我设置了 Git 自动同步 Logseq 笔记,每次 push 都触发博客部署将太频繁。因此将触发动作设定为定时触发:
on:
schedule:
- cron: '0 */6 * * *' # 每 6 小时触发
env:
TZ: 'Asia/Shanghai'配置 publish 范围,修改 config.edn:
;; 如果想要全部公开,就设置为 true,否则就单文章进行 public 属性设置
:publishing/all-pages-public? false
:default-home {:page "README" :sidebar ["contents"]}部署到 Vercel
个人博客:https://www.ai4me.pro
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。