Skip to content

Commit 7dbe333

Browse files
oto-macenauerclaude
andcommitted
fix: align build and docs with knowledge base contract v1
- theme/style.css: add the --color-kb-600 token required by contract/HEADLESS_RULES.md - scripts/pack.py: force UTF-8 on stdout/stderr so the progress glyphs do not crash on a Windows console (cp1252) - scripts/pack.sh: render the showcase from data/showcase.yml like pack.py does instead of copying the unrendered showcase.html Jinja template; copy admin/ for standalone builds only - docs/test-page.md: order 6 (was a duplicate of publishing.md's 5); kb-docs.json pages regenerated - docs, CLAUDE.md: describe the showcase as raw HTML in data/showcase.yml wrapped at build time; fix the standalone HTML page instructions Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NgL7U6ED5aQQbpDa1qsvcU
1 parent acb4a99 commit 7dbe333

8 files changed

Lines changed: 60 additions & 24 deletions

File tree

‎CLAUDE.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Set `SKIP_PIP_INSTALL=1` to skip automatic pip install in managed environments.
3636
2. Auto-generate nav from `docs/` frontmatter (title, order, section) + wiki pages
3737
3. Write merged config to temporary `mkdocs-build.yml`
3838
4. Run `mkdocs build` against merged config
39-
5. Render `showcase.html` template with `data/showcase.yml` → `dist/index.html` (headless strips `<nav>` and adds `data-kb-headless="true"`)
39+
5. Wrap the raw HTML under `content:` in `data/showcase.yml` into `dist/index.html` (headless strips the `<nav>` between the Navigation markers and adds `data-kb-headless="true"`)
4040
6. Copy `showcase.css` → `dist/showcase.css` (`admin/` too, standalone only)
4141
7. Write the computed `pages` list into `apps[0].pages` of `kb-docs.json` (in place; only that key is touched)
4242
8. `--pack` only: verify headless rules and pack `kb-docs.tar.gz`
@@ -52,7 +52,7 @@ docs/ → Markdown source files with YAML frontmatter
5252
data/showcase.yml → Showcase landing page content (CMS-editable)
5353
theme/main.html → Jinja2 page template (branded, dark mode toggle)
5454
theme/style.css → Pre-compiled Tailwind CSS (edit Tailwind source to regenerate)
55-
showcase.html → Jinja2 template for showcase (rendered from data/showcase.yml)
55+
showcase.html → legacy Jinja2 showcase template; NOT used by the build (content lives in data/showcase.yml)
5656
showcase.css → Showcase page styles (copied to dist/ at build time)
5757
scripts/pack.py → Primary build script (cross-platform Python)
5858
scripts/pack.sh → Bash build script (Linux/CI alternative)
@@ -84,7 +84,7 @@ section: Optional Section Name
8484
- Admin panel at `/admin/` — loads Sveltia CMS from CDN
8585
- Backend: GitHub (configure `backend.repo` in `admin/config.yml`)
8686
- Collections: docs (folder), showcase (file), knowledge base metadata `kb-docs.json` (file)
87-
- Showcase content lives in `data/showcase.yml` — rendered via Jinja2 template at build time
87+
- Showcase content lives in `data/showcase.yml` as raw HTML (`content:` key) — wrapped into a full page at build time
8888
- CMS commits trigger CI build; no separate build step needed
8989

9090
## MkDocs Theme

‎docs/adding-pages.md‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,26 @@ You can also create pages through the CMS at `/admin/`.
3333

3434
## Adding a standalone HTML page
3535

36-
Standalone HTML pages (like `showcase.html`) are copied into `dist/` by the build script — they live alongside the MkDocs output.
36+
Standalone HTML pages are copied into `dist/` by the build script — they live alongside the MkDocs output, next to the showcase landing page.
3737

3838
**Step 1** — Create your HTML file at the repo root:
3939

4040
```
4141
knowledge-base-docs-example/
42-
├── showcase.html
42+
├── showcase.css
4343
└── calculator.html ← new standalone page
4444
```
4545

46-
**Step 2** — In `scripts/pack.py`, add a copy line in the section that handles showcase assets:
46+
Give it `data-kb-headless="true"` on `<html>`, no `<base>`, and only relative
47+
`href`/`src` paths — the publish action checks every HTML file in `dist/`.
4748

48-
```bash
49-
cp calculator.html dist/calculator.html
49+
**Step 2** — In `scripts/pack.py`, copy it next to the showcase in `render_showcase()`:
50+
51+
```python
52+
shutil.copy2("calculator.html", "dist/calculator.html")
5053
```
5154

52-
**Step 3** — Link to it from any Markdown page using a root-relative path:
55+
**Step 3** — Link to it from any Markdown page using a relative path:
5356

5457
```markdown
5558
[Open the calculator](../calculator.html)

‎docs/customising.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ theme:
7878

7979
## Showcase landing page
8080

81-
The landing page at `dist/index.html` is rendered from `data/showcase.yml` through a Jinja2 template (`showcase.html`). Edit the YAML file to change headings, feature cards, steps, and CTA buttons — or use the CMS at `/admin/` for a visual editor.
81+
The landing page at `dist/index.html` is the raw HTML stored under `content:` in `data/showcase.yml`, wrapped into a full page by the build script. Edit that HTML to change headings, feature cards, steps, and CTA buttons — or use the CMS at `/admin/` for a live-preview editor. Keep the `<!-- ── Navigation ── -->` … `<!-- ── /Navigation ── -->` markers around the `<nav>`: the headless build removes exactly that block.
8282

8383
Styles live in `showcase.css`. Design tokens are at the top of the file.
8484

‎docs/test-page.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Test page
3-
order: 5
3+
order: 6
44
section: Playground
55
---
66
This is some testing page ... !

‎kb-docs.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
{
3737
"title": "Test page",
3838
"path": "docs/test-page/index.html",
39-
"order": 5,
39+
"order": 6,
4040
"section": "Playground"
4141
}
4242
]

‎scripts/pack.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
from pathlib import Path
5050

5151

52+
# Windows consoles default to a legacy code page that cannot encode the
53+
# progress glyphs printed below; force UTF-8 so a local build does not crash.
54+
for _stream in (sys.stdout, sys.stderr):
55+
if hasattr(_stream, "reconfigure"):
56+
_stream.reconfigure(encoding="utf-8", errors="replace")
57+
58+
5259
# ── Knowledge base contract (contract/ARTIFACT.md in AbsaOSS/knowledge-base) ──
5360
MANIFEST = "kb-docs.json"
5461
ASSET_NAME = "kb-docs.tar.gz"

‎scripts/pack.sh‎

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,46 @@ if [ ! -f dist/docs/index.html ]; then
223223
fi
224224

225225
if [ "$HEADLESS" = true ]; then
226-
echo "▶ Copying showcase (without nav) as entry point..."
227-
$PYTHON - <<'PY'
228-
import re, pathlib
229-
html = pathlib.Path('showcase.html').read_text(encoding='utf-8')
230-
html = re.sub(r'<!-- ── Navigation ── -->\s*<nav[^>]*>.*?</nav>', '', html, flags=re.DOTALL)
231-
# The knowledge base verifies every HTML file carries the headless marker on <html>.
232-
html = re.sub(r'<html\b', '<html data-kb-headless="true"', html, count=1)
233-
pathlib.Path('dist/index.html').write_text(html, encoding='utf-8')
234-
PY
226+
echo "▶ Rendering showcase (headless)..."
235227
else
236-
echo "▶ Copying showcase as entry point..."
237-
cp showcase.html dist/index.html
228+
echo "▶ Rendering showcase..."
238229
fi
230+
# Same as render_showcase() in pack.py: the raw HTML under `content:` in
231+
# data/showcase.yml is wrapped into a full page; headless drops the <nav> block
232+
# between the Navigation markers and stamps the headless marker on <html>.
233+
HEADLESS=$HEADLESS $PYTHON - <<'PY'
234+
import os, pathlib, re, yaml
235+
headless = os.environ.get('HEADLESS') == 'true'
236+
data = yaml.safe_load(pathlib.Path('data/showcase.yml').read_text(encoding='utf-8')) or {}
237+
content = data.get('content', '')
238+
if not content:
239+
print(' ⚠ data/showcase.yml has no content — skipping showcase render')
240+
raise SystemExit(0)
241+
if headless:
242+
content = re.sub(r'<!-- ── Navigation ── -->\s*<nav[^>]*>.*?</nav>\s*<!-- ── /Navigation ── -->',
243+
'', content, flags=re.DOTALL)
244+
attrs = ' data-kb-headless="true"' if headless else ''
245+
html = f"""<!DOCTYPE html>
246+
<html lang="en"{attrs}>
247+
<head>
248+
<meta charset="UTF-8" />
249+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
250+
<title>Showcase</title>
251+
<link rel="stylesheet" href="docs/style.css" />
252+
<link rel="stylesheet" href="showcase.css" />
253+
</head>
254+
<body>
255+
{content}
256+
</body>
257+
</html>"""
258+
pathlib.Path('dist/index.html').write_text(html, encoding='utf-8')
259+
PY
239260
[ -f showcase.css ] && cp showcase.css dist/showcase.css
261+
# The CMS is part of the standalone site only; its pages would fail the
262+
# knowledge base's headless verification.
263+
if [ "$HEADLESS" != true ] && [ -d admin ]; then
264+
cp -r admin dist/admin
265+
fi
240266

241267
echo "▶ Updating $MANIFEST pages manifest..."
242268
update_manifest_pages

‎theme/style.css‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)