diff --git a/.github/workflows/website.yaml b/.github/workflows/website.yaml index 3e858cdbb..280e1b40b 100644 --- a/.github/workflows/website.yaml +++ b/.github/workflows/website.yaml @@ -27,7 +27,7 @@ jobs: - name: Build the site run: zensical build --strict --config-file website/mkdocs.yml - - name: Post-build (redirects and analytics) + - name: Post-build (analytics) run: bash website/post-build.sh website/rendered - name: Publish to Cloudflare Pages diff --git a/website/mkdocs.yml b/website/mkdocs.yml index 10b683586..8dedcb5c7 100644 --- a/website/mkdocs.yml +++ b/website/mkdocs.yml @@ -75,6 +75,23 @@ theme: name: Switch to light mode plugins: - search: + - minify: + minify_html: true + minify_js: true + minify_css: true + htmlmin_opts: + remove_comments: true + cache_safe: true + - redirects: + redirect_maps: + 'getting_started.md': 'getting-started.md' + 'development/index.md': 'development/contributing.md' + 'development/controller-design.md': 'development/controller-implementation.md' + 'development/design-decisions.md': 'concepts/design-principles.md' + 'development/coding-convention.md': 'development/coding-standards.md' + 'development/api-contracts.md': 'development/api-design.md' + 'user-guide/index.md': 'concepts/core-concepts.md' + 'user-guide/drift-detection.md': 'concepts/drift-detection.md' markdown_extensions: - admonition - attr_list diff --git a/website/post-build.sh b/website/post-build.sh index 7073246b2..462ab14eb 100644 --- a/website/post-build.sh +++ b/website/post-build.sh @@ -1,67 +1,16 @@ #!/bin/bash # Post-build script for zensical/mkdocs site. -# Generates redirect pages and analytics proxy endpoint. +# Generates the analytics proxy endpoint. +# +# Redirects and HTML/asset minification are now handled natively by +# zensical's built-in `redirects` and `minify` plugin replacements +# (see mkdocs.yml), so this script only needs to cover what zensical +# doesn't support yet: arbitrary MkDocs `hooks`. set -euo pipefail SITE_DIR="${1:?Usage: $0 }" -# --- Redirects --- -# Replaces mkdocs-redirects plugin. Each entry maps an old path (directory URL) -# to a new relative URL. -declare -A REDIRECTS=( - ["getting_started"]="../getting-started/" - ["development/controller-design"]="../controller-implementation/" - ["development/design-decisions"]="../../concepts/design-principles/" - ["development/coding-convention"]="../coding-standards/" - ["development/api-contracts"]="../api-design/" - ["user-guide/drift-detection"]="../../concepts/drift-detection/" -) - -# index.md redirects are special: they build to /index.html directly -declare -A INDEX_REDIRECTS=( - ["development"]="contributing/" - ["user-guide"]="../concepts/core-concepts/" -) - -for src in "${!REDIRECTS[@]}"; do - dest="${REDIRECTS[$src]}" - dir="$SITE_DIR/$src" - mkdir -p "$dir" - cat > "$dir/index.html" < - - - - - - - -

This page has moved. If you are not redirected, click here.

- - -EOF -done - -for src in "${!INDEX_REDIRECTS[@]}"; do - dest="${INDEX_REDIRECTS[$src]}" - dir="$SITE_DIR/$src" - mkdir -p "$dir" - cat > "$dir/index.html" < - - - - - - - -

This page has moved. If you are not redirected, click here.

- - -EOF -done - # --- Analytics proxy endpoint --- # Replaces hooks.py on_post_build. Creates an empty script for the Plausible # analytics reverse-proxy setup. diff --git a/website/requirements.txt b/website/requirements.txt index ab6617313..2446fb53d 100644 --- a/website/requirements.txt +++ b/website/requirements.txt @@ -1 +1 @@ -zensical==0.0.56 +zensical==0.0.59