Integrate Tiddlywiki into Hexo and deploy it together

Posted by taldos on Sat, 22 Jan 2022 07:05:11 +0100

Recently, I was looking for a wiki to record some systematic knowledge and notes TiddlyWiki This thing. TiddlyWiki is a non network application Wiki program composed of only a single HTML file. It does not rely on the database to store data. It is very distinctive. It can install plug-ins and play more ways.

Since the final release to the Internet is static files, it can be deployed together with Hexo. There is no need to build a service to put single HTML files of TiddlyWiki, and version management can be done together.

We can put the single HTML file of TiddlyWiki into the public/wiki folder of Hexo, and put a / wiki entry on the website, which can be accessed with the submission and deployment of Hexo. However, as more wikis are written, the generated single HTML files become larger and larger, and the push is also slow. We don't use this method. In fact, we only care about writing, and all other troublesome things can be done by GitHub Action or other automated deployment tools. Here are the steps of integration.

integration

Install TiddlyWiki first:

npm install -g tiddlywiki
tiddlywiki  --version

Initialize a TiddlyWiki in the Hexo root directory:

tiddlywiki tiddlywiki --init server

The source file of the wiki we wrote is placed in the tiddlywiki/tiddlers folder, similar to Hexo's source/_ The posts folder.

Add a wiki entry to the Hexo theme configuration:

menu:
  Home: /
  Archives: /archives
  About: /about
  wiki: /wiki

Modify GitHub Action script

name: CI
on:
  push:
    branches:
      - hexo-blog
jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout source
        uses: actions/checkout@v1
        with:
          ref: hexo-blog
      - name: Setup node 
        uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - name: Setup hexo
        env:
          ACTION_DEPLOY_KEY: ${{ secrets.HEXO_DEPLOY_PRI }}
        run: |
          mkdir -p ~/.ssh/
          echo "$ACTION_DEPLOY_KEY" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          git config --global user.email "xx@xx.com"
          git config --global user.name "yourname"
          npm install hexo-cli -g
          npm install tiddlywiki -g
          npm install
      - name: Hexo deploy
        run: |
          hexo clean
          hexo g
          tiddlywiki tiddlywiki --build index
          mkdir public/wiki
          mv tiddlywiki/output/index.html public/wiki
          hexo d
  • npm install tiddlywiki -g install tiddlywiki
  • hexo g generates static files into the public folder;
  • tiddlywiki tiddlywiki --build index output index HTML file to tiddlywiki/output folder;
  • Create a wiki folder in public, and then put index The HTML will be over.

There is another way to create a wiki directory in the source folder, and then modify the GitHub Action script to index HTML file, then move it to the source/wiki directory, and then hexo g compile it. Change it to this way, and test it by yourself:

- name: Hexo deploy
  run: |
    hexo clean
    mkdir source/wiki
    tiddlywiki tiddlywiki --build index
    mv tiddlywiki/output/index.html source/wiki
    # hexo g should not be written
    hexo g
    hexo d

However, set Hexo instead of index Html is also compiled:

# _ config.yml skip_render configuration, compile and render, and ignore all files under the wiki
skip_render: [wiki/**]

effect:

reference resources

Topics: hexo