Skip to content

Commit b7f9d79

Browse files
ci: Setup netlify-build-docs
1 parent b825df6 commit b7f9d79

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

netlify-build-docs.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
set -euxo pipefail
3+
4+
# 1. Install tools
5+
6+
curl -sS https://webi.sh/sd | sh && source ~/.config/envman/PATH.env
7+
curl https://mise.run | sh
8+
9+
# 2. Clone typst-jp.github.io
10+
11+
# Tested against https://github.com/typst-jp/typst-jp.github.io/commit/f588f0d53dbb39225739fa7faeecb33d9b4b055b
12+
git clone --depth 1 --no-checkout --filter=tree:0 https://github.com/typst-jp/typst-jp.github.io ../jp
13+
cd ../jp
14+
git sparse-checkout init
15+
git sparse-checkout set website/ tsconfig.json package.json bun.lockb .mise.toml
16+
git switch main
17+
cd -
18+
19+
# 3. Move files from typst-jp
20+
21+
cat << EOF >> .gitignore
22+
# From typst-jp
23+
/website/
24+
/tsconfig.json
25+
/package.json
26+
/bun.lockb
27+
/.mise.toml
28+
29+
# Generated
30+
/assets/docs/
31+
/assets/docs.json
32+
EOF
33+
34+
# This `cp -r` cannot be replaced with `ln -s`, because there will be a symlink created in website/public
35+
cp -r ../jp/website/ .
36+
ln -s ../jp/{tsconfig.json,package.json,bun.lockb} .
37+
cp ../jp/.mise.toml .
38+
39+
# The rust edition has been bumped to 2024 in https://github.com/typst/typst/pull/6637
40+
sd --fixed-strings \
41+
'rust = "1.83.0"' \
42+
'rust = "1.88.0"' \
43+
.mise.toml
44+
45+
# Use canonical typst-docs for `mise run generate-docs`
46+
sd --fixed-strings \
47+
'run = "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture"' \
48+
'run = "cargo run --package typst-docs -- --assets-dir assets/docs --out-file assets/docs.json --base /docs/"' \
49+
.mise.toml
50+
mkdir -p website/public/docs
51+
sd --fixed-strings \
52+
'const publicAssetsDocsPath = resolve(__dirname, "./public/assets/docs/");' \
53+
'const publicAssetsDocsPath = resolve(__dirname, "./public/docs/assets/");' \
54+
website/vite.config.ts
55+
56+
# 4. Build
57+
58+
mise trust
59+
mise install
60+
mise run generate
61+
62+
# For dev: Run `mise run dev`
63+
# For deploy: Upload website/dist

netlify.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build]
2+
command = "bash ./netlify-build-docs.sh"
3+
publish = "website/dist"

0 commit comments

Comments
 (0)