Skip to content

Commit 68005c5

Browse files
committed
website: migrate from mkdocs to zensical
Replace mkdocs-material with zensical, since mkdocs v1 is no longer maintained. Zensical reads mkdocs.yml natively, so no config format conversion is needed. - Replace mkdocs-material, mkdocs-minify-plugin, mkdocs-redirects with zensical in requirements.txt - Remove unsupported plugin configs (minify, redirects) and hooks from mkdocs.yml; add site_dir: rendered - Add website/post-build.sh to generate redirect HTML pages and the Plausible analytics proxy endpoint, replacing the mkdocs-redirects plugin and hooks.py respectively - Delete hooks.py (superseded by post-build.sh) - Update CI workflow to use zensical build and run the post-build script
1 parent 69fb7ed commit 68005c5

5 files changed

Lines changed: 93 additions & 29 deletions

File tree

.github/workflows/website.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ jobs:
2525
run: pip install -Ur website/requirements.txt
2626

2727
- name: Build the site
28-
run: mkdocs build --verbose --strict --config-file website/mkdocs.yml --site-dir rendered
28+
run: zensical build --strict --config-file website/mkdocs.yml
29+
30+
- name: Post-build (redirects and analytics)
31+
run: bash website/post-build.sh website/rendered
2932

3033
- name: Publish to Cloudflare Pages
3134
uses: cloudflare/pages-action@f0a1cd58cd66095dee69bfa18fa5efd1dde93bca # tag=v1.5.0

website/hooks.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

website/mkdocs.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ extra:
4747
link: https://github.com/k-orc/openstack-resource-controller
4848
- icon: fontawesome/brands/slack
4949
link: slack://channel?team=T09NY5SBT&id=C05G4NJ6P6X
50-
hooks:
51-
- hooks.py
50+
site_dir: rendered
5251
theme:
5352
name: material
5453
custom_dir: overrides
@@ -63,25 +62,26 @@ theme:
6362
- search.highlight
6463
- search.suggest
6564
- toc.integrate
65+
palette:
66+
# Palette toggle for automatic mode
67+
- media: "(prefers-color-scheme)"
68+
toggle:
69+
icon: lucide/sun-moon
70+
name: Switch to light mode
71+
# Palette toggle for light mode
72+
- media: "(prefers-color-scheme: light)"
73+
scheme: default
74+
toggle:
75+
icon: lucide/sun
76+
name: Switch to dark mode
77+
# Palette toggle for dark mode
78+
- media: "(prefers-color-scheme: dark)"
79+
scheme: slate
80+
toggle:
81+
icon: lucide/moon
82+
name: Switch to system preference
6683
plugins:
6784
- search:
68-
- minify:
69-
minify_html: true
70-
minify_js: true
71-
minify_css: true
72-
htmlmin_opts:
73-
remove_comments: true
74-
cache_safe: true
75-
- redirects:
76-
redirect_maps:
77-
'getting_started.md': 'getting-started.md'
78-
'development/index.md': 'development/contributing.md'
79-
'development/controller-design.md': 'development/controller-implementation.md'
80-
'development/design-decisions.md': 'concepts/design-principles.md'
81-
'development/coding-convention.md': 'development/coding-standards.md'
82-
'development/api-contracts.md': 'development/api-design.md'
83-
'user-guide/index.md': 'concepts/core-concepts.md'
84-
'user-guide/drift-detection.md': 'concepts/drift-detection.md'
8585
markdown_extensions:
8686
- admonition
8787
- attr_list

website/post-build.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
# Post-build script for zensical/mkdocs site.
3+
# Generates redirect pages and analytics proxy endpoint.
4+
5+
set -euo pipefail
6+
7+
SITE_DIR="${1:?Usage: $0 <site-dir>}"
8+
9+
# --- Redirects ---
10+
# Replaces mkdocs-redirects plugin. Each entry maps an old path (directory URL)
11+
# to a new relative URL.
12+
declare -A REDIRECTS=(
13+
["getting_started"]="../getting-started/"
14+
["development/controller-design"]="../controller-implementation/"
15+
["development/design-decisions"]="../../concepts/design-principles/"
16+
["development/coding-convention"]="../coding-standards/"
17+
["development/api-contracts"]="../api-design/"
18+
["user-guide/drift-detection"]="../../concepts/drift-detection/"
19+
)
20+
21+
# index.md redirects are special: they build to <dir>/index.html directly
22+
declare -A INDEX_REDIRECTS=(
23+
["development"]="contributing/"
24+
["user-guide"]="../concepts/core-concepts/"
25+
)
26+
27+
for src in "${!REDIRECTS[@]}"; do
28+
dest="${REDIRECTS[$src]}"
29+
dir="$SITE_DIR/$src"
30+
mkdir -p "$dir"
31+
cat > "$dir/index.html" <<EOF
32+
<!DOCTYPE html>
33+
<html>
34+
<head>
35+
<meta charset="utf-8">
36+
<meta http-equiv="refresh" content="0; url=$dest">
37+
<link rel="canonical" href="$dest">
38+
</head>
39+
<body>
40+
<p>This page has moved. If you are not redirected, <a href="$dest">click here</a>.</p>
41+
</body>
42+
</html>
43+
EOF
44+
done
45+
46+
for src in "${!INDEX_REDIRECTS[@]}"; do
47+
dest="${INDEX_REDIRECTS[$src]}"
48+
dir="$SITE_DIR/$src"
49+
mkdir -p "$dir"
50+
cat > "$dir/index.html" <<EOF
51+
<!DOCTYPE html>
52+
<html>
53+
<head>
54+
<meta charset="utf-8">
55+
<meta http-equiv="refresh" content="0; url=$dest">
56+
<link rel="canonical" href="$dest">
57+
</head>
58+
<body>
59+
<p>This page has moved. If you are not redirected, <a href="$dest">click here</a>.</p>
60+
</body>
61+
</html>
62+
EOF
63+
done
64+
65+
# --- Analytics proxy endpoint ---
66+
# Replaces hooks.py on_post_build. Creates an empty script for the Plausible
67+
# analytics reverse-proxy setup.
68+
mkdir -p "$SITE_DIR/t/p"
69+
touch "$SITE_DIR/t/p/script.js"

website/requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
mkdocs-material
2-
mkdocs-minify-plugin
3-
mkdocs-redirects
1+
zensical

0 commit comments

Comments
 (0)