From ec868fb62ee0fb08f0b76c565dbff4156503c4ce Mon Sep 17 00:00:00 2001
From: "Y.D.X." <73375426+YDX-2147483647@users.noreply.github.com>
Date: Mon, 27 Oct 2025 17:58:27 +0800
Subject: [PATCH 1/4] ci(netlify): initial setup
---
netlify-build.sh | 137 +++++++++++++++++++++++++++++++++++++++++++++++
netlify.toml | 3 ++
2 files changed, 140 insertions(+)
create mode 100644 netlify-build.sh
create mode 100644 netlify.toml
diff --git a/netlify-build.sh b/netlify-build.sh
new file mode 100644
index 0000000..b810da9
--- /dev/null
+++ b/netlify-build.sh
@@ -0,0 +1,137 @@
+#!/usr/bin/env bash
+set -euxo pipefail
+
+# 1. Install tools
+
+curl -sS https://webi.sh/sd | sh && source ~/.config/envman/PATH.env
+curl https://mise.run | sh
+
+# 2. Install dependencies
+
+mise trust
+mise install
+mise exec -- bun install
+
+# 3. Prepare common files
+
+mkdir _site
+
+# Prepare favicon
+curl -L https://github.com/typst-community/org/raw/main/design/typst-community.icon.png \
+ -o _site/favicon.png
+cp _site/favicon.png public/favicon.png
+
+# Prepare the index page
+REF=$(git rev-parse --short HEAD)
+DATE=$(git log --max-count=1 --pretty='%cd' --date=iso)
+cat << EOF > _site/index.html
+
+
+
+
+
+ typst-docs-web
+
+
+
+
+
+ Build a website from the documentation JSON file generated by typst-docs.
+ This website is for developing typst-docs-web. Its contents might be changed at anytime.
+
+
+ typst-docs-web version:
+ $REF ($DATE)
+
+
+
+
+EOF
+
+# 4. Build
+# 4.1. Build en-US
+
+build_en_US() {
+ local VERSION="$1"
+
+ BASE="en-US-$VERSION"
+
+ # Prepare docs.json
+ curl -L https://github.com/typst-community/dev-builds/releases/download/docs-"$VERSION"/docs.json \
+ -o public/docs.json
+ sd '/DOCS-BASE/' "/$BASE/" public/docs.json
+
+ # Prepare docs assets
+ curl -LO https://github.com/typst-community/dev-builds/releases/download/docs-"$VERSION"/docs-assets.zip
+ unzip docs-assets.zip && rm docs-assets.zip
+ mv assets public/assets
+
+ # Configure metadata
+ cat << EOF > public/metadata.json
+{
+ "\$schema": "../metadata.schema.json",
+ "language": "en-US",
+ "version": "${VERSION#v}",
+ "typstOfficialUrl": "https://typst.app",
+ "typstOfficialDocsUrl": "https://typst.app/docs/",
+ "githubOrganizationUrl": "https://github.com/typst-community",
+ "githubRepositoryUrl": "https://github.com/typst-community/typst-docs-web",
+ "discordServerUrl": "https://discord.gg/2uDybryKPe",
+ "originUrl": "$DEPLOY_URL/",
+ "basePath": "/$BASE/",
+ "displayTranslationStatus": false
+}
+EOF
+ # $DEPLOY_URL is set by netlify.
+ # https://docs.netlify.com/build/configure-builds/environment-variables/#deploy-urls-and-metadata
+
+ # Build
+ mise exec -- bun run build
+ mv dist _site/"$BASE"
+
+ # Clean
+ rm -r public/{docs.json,assets,metadata.json}
+}
+
+build_en_US v0.14.0
+build_en_US v0.13.1
+
+# 4.2. Build ja-JP
+
+# Prepare files
+mise exec -- bun run fetch-docs-ja-jp
+sd '"/docs/' '"/ja-JP/' public/docs.json
+sd --fixed-strings \
+ '"basePath": "/docs/",' \
+ '"basePath": "/ja-JP/",' \
+ public/metadata.json
+
+# Build
+mise exec -- bun run build
+mv dist _site/ja-JP
+
+# Clean
+rm -r public/{docs,metadata,translation-status}.json
diff --git a/netlify.toml b/netlify.toml
new file mode 100644
index 0000000..5816a23
--- /dev/null
+++ b/netlify.toml
@@ -0,0 +1,3 @@
+[build]
+command = "bash netlify-build.sh"
+publish = "_site"
From f3475e507cb7808c294f95763fde35de09a8ef8e Mon Sep 17 00:00:00 2001
From: "Y.D.X." <73375426+YDX-2147483647@users.noreply.github.com>
Date: Thu, 30 Oct 2025 10:46:55 +0800
Subject: [PATCH 2/4] Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: 3w36zj6 <52315048+3w36zj6@users.noreply.github.com>
---
netlify-build.sh | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/netlify-build.sh b/netlify-build.sh
index b810da9..bdf0888 100644
--- a/netlify-build.sh
+++ b/netlify-build.sh
@@ -3,14 +3,12 @@ set -euxo pipefail
# 1. Install tools
-curl -sS https://webi.sh/sd | sh && source ~/.config/envman/PATH.env
curl https://mise.run | sh
-
# 2. Install dependencies
mise trust
mise install
-mise exec -- bun install
+mise exec -- bun install --frozen-lockfile
# 3. Prepare common files
From 29e102ea7c42bf13417af0648c59b72b43313100 Mon Sep 17 00:00:00 2001
From: "Y.D.X." <73375426+YDX-2147483647@users.noreply.github.com>
Date: Thu, 30 Oct 2025 10:55:53 +0800
Subject: [PATCH 3/4] Apply suggestions
---
netlify-build.sh | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/netlify-build.sh b/netlify-build.sh
index bdf0888..4085cc7 100644
--- a/netlify-build.sh
+++ b/netlify-build.sh
@@ -1,16 +1,14 @@
#!/usr/bin/env bash
set -euxo pipefail
-# 1. Install tools
+# 1. Install tools and dependencies
curl https://mise.run | sh
-# 2. Install dependencies
-
mise trust
mise install
mise exec -- bun install --frozen-lockfile
-# 3. Prepare common files
+# 2. Prepare common files
mkdir _site
@@ -69,8 +67,8 @@ cat << EOF > _site/index.html