|
6 | 6 |
|
7 | 7 | 1. Injects the custom version selector <script> tag into all HTML files. |
8 | 8 | 2. Generates versions.json (flat array with url fields). |
9 | | -3. Generates redirect index.html files: |
10 | | - - /docs/default/ and /docs/default/spec/ are stable permalinks that track |
11 | | - the current default branch, so external links survive the rollover from |
12 | | - e.g. forks/amsterdam to forks/bogota. |
13 | | - - /docs/ and /docs/spec/ forward to those permalinks for backward compat. |
| 9 | +3. Generates /docs/default/ — a stable permalink that tracks the current |
| 10 | + default branch, so external links survive the rollover from e.g. |
| 11 | + forks/amsterdam to forks/bogota. |
| 12 | + /docs/ itself is the Zensical-built landing page and is not overwritten. |
14 | 13 |
|
15 | 14 | Usage (from repo root): |
16 | 15 | uv run scripts/assemble-docs.py site/docs \\ |
@@ -110,30 +109,19 @@ def generate_versions_json( |
110 | 109 |
|
111 | 110 |
|
112 | 111 | def generate_redirects(docs_dir: Path, default_branch: str) -> None: |
113 | | - """Generate permalink redirects under docs/default/ and forwarders at docs root. |
| 112 | + """Generate the /docs/default/ permalink redirect. |
114 | 113 |
|
115 | | - /docs/default/ and /docs/default/spec/ are the stable permalinks — they |
116 | | - track the current default branch and survive its rollover. /docs/ and |
117 | | - /docs/spec/ forward through the permalinks so the old URLs keep working. |
| 114 | + /docs/default/ tracks the current default branch so external links survive |
| 115 | + the rollover from e.g. forks/amsterdam to forks/bogota. |
| 116 | +
|
| 117 | + /docs/ itself is the Zensical-built landing page (docs/docs/index.md) and |
| 118 | + is intentionally not written here so we don't overwrite it. |
118 | 119 | """ |
119 | | - branch_url = f"/docs/{default_branch}/" |
120 | | - branch_spec_url = f"/docs/{default_branch}/specs/reference/" |
121 | | - targets = [ |
122 | | - # Permalinks: /docs/default/... -> current default branch. |
123 | | - (docs_dir / "default" / "index.html", branch_url, default_branch), |
124 | | - ( |
125 | | - docs_dir / "default" / "spec" / "index.html", |
126 | | - branch_spec_url, |
127 | | - f"{default_branch}/specs/reference", |
128 | | - ), |
129 | | - # Forwarders: /docs/ and /docs/spec/ -> /docs/default/... |
130 | | - (docs_dir / "index.html", "/docs/default/", "default"), |
131 | | - (docs_dir / "spec" / "index.html", "/docs/default/spec/", "default/spec"), |
132 | | - ] |
133 | | - for dest, url, label in targets: |
134 | | - dest.parent.mkdir(parents=True, exist_ok=True) |
135 | | - dest.write_text(REDIRECT_TEMPLATE.format(url=url, label=label)) |
136 | | - print(f"Generated redirect: {dest.relative_to(docs_dir)} -> {url}") |
| 120 | + dest = docs_dir / "default" / "index.html" |
| 121 | + url = f"/docs/{default_branch}/" |
| 122 | + dest.parent.mkdir(parents=True, exist_ok=True) |
| 123 | + dest.write_text(REDIRECT_TEMPLATE.format(url=url, label=default_branch)) |
| 124 | + print(f"Generated redirect: {dest.relative_to(docs_dir)} -> {url}") |
137 | 125 |
|
138 | 126 |
|
139 | 127 | def main() -> None: |
|
0 commit comments