From b67b1336254badbae782b19ad63b7516452acc1e Mon Sep 17 00:00:00 2001 From: aterenin Date: Sun, 31 Mar 2024 01:44:26 +0200 Subject: [PATCH] Add server-side KaTeX. --- .github/workflows/deploy.yml | 18 ++++++++++++++++-- config.toml | 3 ++- themes/academic-paper | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6ea9159..7a8154d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,11 +24,25 @@ jobs: with: submodules: 'recursive' - name: Download Zola - run: curl -fLsS "https://github.com/getzola/zola/releases/download/v0.17.2/zola-v0.17.2-x86_64-unknown-linux-gnu.tar.gz" | tar xzf - -C /usr/local/bin + run: curl -fLsS "https://github.com/getzola/zola/releases/download/v0.18.0/zola-v0.18.0-x86_64-unknown-linux-gnu.tar.gz" | tar xzf - -C /usr/local/bin - name: Verify Zola binary - run: echo "b62c19a1e104a0526a48a1f29c05ba90b9a14fe7a17ef6a7978d9610886cc783 /usr/local/bin/zola" | shasum -a 256 -b -c --strict + run: echo "3530d2626c3adcdc5cfcbfab0b736751269acd6f5352eaf60c3e105d939c8e74 /usr/local/bin/zola" | shasum -a 256 -b -c --strict - name: Build website run: zola build + - name: Check for server side KaTeX + run: grep -c "server_side_katex\s*=\s*true" config.toml | sed s/1/SERVER_SIDE_KATEX=true/ >> $GITHUB_ENV + - name: Setup Node + uses: actions/setup-node@v4 + if: ${{ env.SERVER_SIDE_KATEX == 'true' }} + - name: Install KaTeX + run: npm install katex + if: ${{ env.SERVER_SIDE_KATEX == 'true' }} + - name: Find KaTeX script directory + run: if [ -d scripts ]; then echo "KATEX_SCRIPT_DIR=scripts"; else echo "KATEX_SCRIPT_DIR=themes/academic-paper/scripts"; fi >> $GITHUB_ENV + if: ${{ env.SERVER_SIDE_KATEX == 'true' }} + - name: Render KaTeX + run: node $KATEX_SCRIPT_DIR/katex.js + if: ${{ env.SERVER_SIDE_KATEX == 'true' }} - name: Upload artifact uses: actions/upload-pages-artifact@v2 with: diff --git a/config.toml b/config.toml index 3fa8424..f9dda74 100644 --- a/config.toml +++ b/config.toml @@ -11,4 +11,5 @@ highlight_theme = "css" smart_punctuation = true [extra] -google_analytics = "G-GB3BZDSEMD" \ No newline at end of file +google_analytics = "G-GB3BZDSEMD" +server_side_katex = true \ No newline at end of file diff --git a/themes/academic-paper b/themes/academic-paper index 70b1f2a..eece902 160000 --- a/themes/academic-paper +++ b/themes/academic-paper @@ -1 +1 @@ -Subproject commit 70b1f2a992c2f5de16b4b9f1d908c5202cf3244f +Subproject commit eece902c72c7f3fab74b5accabb9813660f7a220