Make it easier for you to publish your Logseq graph as your own digital garden.
Due to file size limitations on Github, the following files have not been uploaded, but you can download the complete package in releases.
/publish-spa/
/OtherDependencies/
/logseq/
/Node/
- Brief Introduction
- Getting Started
- Change Page Styles
- File Directory Description
- Other Projects Used in This Project
- Integrate with Logseq's automatic commit function, implementing the Git hook to execute automation processes (the content of the process is as follows):
- Convert image formats (except gif) to
avif
to save space, without changing the file name. - Generate a webpage of the Logseq graph using
Logseq-Publish-spa
. - Upload the Logseq graph webpage to Github and publish it.
- Automatically delete Github deployments and workflow records.
- Currently, only usable on Windows computers.
- Ensure that Git is usable on your computer.
- Logseq has been installed.
- JDK17 or above has been installed.
Download and add babashka
to your environment variables.
You can find a version of babashka
in the OtherDependencies
folder of this project, or download the latest version from babashka's releases.
You can find the Clojure MSI file in the OtherDependencies
folder of this project for installation, or download the latest version from Clojure's releases.
In the project directory, first clone Logseq.
git clone https://github.com/logseq/logseq
Then enter the logseq
directory, install dependencies, and generate the template. (Why don't I install and then package? Because this step will increase the entire project volume by nearly 2G, I think it's better to install it yourself. Other dependencies are already installed).
cd logseq
$env:Path += ";$((Convert-Path -Path '../Node/'))" # Temporarily add ../Node/ to environment variables
yarn install --frozen-lockfile # Note the network connection here; it might disconnect if the network is not good and need to re-execute
yarn gulp:build
clojure -M:cljs release publishing
If the following error occurs, please modify the PowerShell execution script permissions.
../Node/yarn : File ......\LogseqDigitalGardenTemplate\Node\yarn.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
Location Line:1 Char: 1
+ ../Node/yarn install --frozen-lockfile
+ ~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Modify permissions command to allow the current user to execute local scripts.
Set-ExecutionPolicy Remotesigned -Scope CurrentUser
In /publish-spa/
, execute:
$env:Path += ";$((Convert-Path -Path '../Node/'))" # Temporarily add ../Node/ to environment variables
npm i -g
Use Logseq to initialize a graph in the /GraphsFile/
directory. Generally, if there are no images in the graph, there will be no assets
file in this directory. However, for debugging purposes, you can create one yourself first.
Then, initialize a Git file in this directory.
Execute the following commands:
git init
git add -A
git commit -m "Init"
Then, put the two scripts in the /GitHookBak/
directory into the /GraphsFile/.git/hook/
directory.
In this directory, two workflows have been written. delete-workflow-runs.yml
is used to automatically delete Github deployments and workflow records, while static.yml
is used to generate a Github Page.
But remember to change the repository name in /.github/delete-workflow-runs.yml
to your own.
jobs:
del_runs:
steps:
with:
repository: 'Here write your own github.io repository address'
Create an initial Git in this directory.
git init
git add -A
git commit -m "Init"
Add a Github remote repository.
git branch -M main
git remote add origin <Your Github repository address>
Also, if you are using Git for the first time, remember to configure your Git username and email.
git config --global user.email <Your email>
git config --global user.name <Your Name>
Enable Logseq's automatic commit function (toggling it on/off will execute it once).
Before generating the Logseq webpage, please set which pages to publish in Logseq, or publish all of them.
You can go to logseq/publish-spa to view detailed commands, and then change the ../Node/logseq-publish-spa ../PublishWeb
command in the /GraphsFile/.git/hook/post-commit
file.
filetree
├── /GitHookBak/ # Backup of git hook scripts
│ ├── post-commit
│ └── pre-commit
├── /GraphsFile/ # Stores Logseq graphs
│ ├── /.git/
│ └── ... # Omitted Logseq graph directory structure
├── /ImageToAVIF/ # Scripts for converting images to avif format
├── /Node/ # Nodejs with pre-installed dependencies
├── /OtherDependencies/ # Some dependencies to be installed, perhaps you can download the latest version
├── /publish-spa/ # publish-spa project folder
├── /PublishWeb/ # Generated Logseq graph webpages
│ ├── /.git/
│ └── ... # Omitted Logseq graph webpage directory structure
├── creatWeb.bat # Manually generate webpages, but won't upload
├── ImageToAVIF.bat # Manually convert all images in the graph to the specified format
├── PublishWeb.bat # Manually perform a commit operation on /GraphsFile/, in order to automatically execute hook scripts, realizing manual generation of web
├── README.md
├── TestWebByPython.bat # Use Python to start an HTTP service for testing webpages
└── upload.log # Git hook logs