|
| 1 | +# Documentation site |
| 2 | + |
| 3 | +The browsable docs for [`bcgov/agent-skills`](https://github.com/bcgov/agent-skills). |
| 4 | +Built with a **zero-dependency template engine** (Bash + a tiny Node script) |
| 5 | +and served from GitHub Pages. |
| 6 | + |
| 7 | +## TL;DR |
| 8 | + |
| 9 | +```bash |
| 10 | +cd docs |
| 11 | +./build.sh # build the static site + search index |
| 12 | +open index.html # macOS — use xdg-open on Linux, start on Windows |
| 13 | +``` |
| 14 | + |
| 15 | +## What's in here |
| 16 | + |
| 17 | +``` |
| 18 | +docs/ |
| 19 | +├── _partials/ # Shared header + footer (injected into every page) |
| 20 | +│ ├── header.html |
| 21 | +│ └── footer.html |
| 22 | +│ |
| 23 | +├── _pages/ # Source content — one file per page |
| 24 | +│ ├── _template.html # Starter for new pages (skipped by build) |
| 25 | +│ ├── index.html # Home |
| 26 | +│ ├── catalog.html # Skill catalog |
| 27 | +│ ├── consume.html # How to install a skill |
| 28 | +│ ├── contribute.html # How to add a skill |
| 29 | +│ ├── spec.html # SKILL.md spec summary |
| 30 | +│ ├── architecture.html # Pipeline & governance |
| 31 | +│ └── faq.html # FAQ |
| 32 | +│ |
| 33 | +├── assets/ # Static assets shipped as-is |
| 34 | +│ ├── bc_citz_logo.jpg |
| 35 | +│ ├── favicon.svg |
| 36 | +│ ├── search.js # FlexSearch client wiring |
| 37 | +│ └── search-index.json # Generated — full-text search index |
| 38 | +│ |
| 39 | +├── build.sh # Template engine + search index trigger |
| 40 | +├── generate-search-index.js # Node — parses built HTML → search-index.json |
| 41 | +├── README.md # This file |
| 42 | +│ |
| 43 | +└── *.html # Build output, served by GitHub Pages |
| 44 | +``` |
| 45 | + |
| 46 | +## How the template engine works |
| 47 | + |
| 48 | +Each page in `_pages/` starts with two HTML comments that the build script reads: |
| 49 | + |
| 50 | +```html |
| 51 | +<!-- TITLE: My Page Title --> |
| 52 | +<!-- NAV: catalog --> |
| 53 | + |
| 54 | +<h1>Page content starts here</h1> |
| 55 | +``` |
| 56 | + |
| 57 | +| Metadata | What it does | |
| 58 | +| -------- | ----------------------------------------------------------- | |
| 59 | +| `TITLE` | Substituted into the `<title>` tag and the visible heading | |
| 60 | +| `NAV` | Marks the matching nav item as `active` (uppercased: `NAV_CATALOG`) | |
| 61 | + |
| 62 | +`build.sh` then concatenates `_partials/header.html` + page content + `_partials/footer.html`, replaces `{{PAGE_TITLE}}`, `{{NAV_*}}`, and `{{YEAR}}`, and writes the assembled HTML next to itself at `docs/<page>.html`. |
| 63 | + |
| 64 | +After all pages are written, the script invokes `generate-search-index.js`, which: |
| 65 | + |
| 66 | +1. Walks every `*.html` at the docs root. |
| 67 | +2. Auto-assigns `id=` attributes to any `h1`/`h2`/`h3` missing one (so deep-links work). |
| 68 | +3. Writes `assets/search-index.json`, consumed in the browser by [FlexSearch](https://github.com/nextapps-de/flexsearch) (loaded from a CDN by `assets/search.js`). |
| 69 | + |
| 70 | +## Adding a new page |
| 71 | + |
| 72 | +1. **Create the source file** at `_pages/<slug>.html`: |
| 73 | + |
| 74 | + ```html |
| 75 | + <!-- TITLE: My New Page --> |
| 76 | + <!-- NAV: mynewpage --> |
| 77 | + |
| 78 | + <h1>My New Page</h1> |
| 79 | + <p>Use any HTML. The header bundles all CSS.</p> |
| 80 | + ``` |
| 81 | + |
| 82 | +2. **Add a nav link** in `_partials/header.html`: |
| 83 | + |
| 84 | + ```html |
| 85 | + <a href="mynewpage.html" class="{{NAV_MYNEWPAGE}}">My New Page</a> |
| 86 | + ``` |
| 87 | + |
| 88 | +3. **Add the clear-line** in `build.sh` so inactive instances render blank: |
| 89 | + |
| 90 | + ```bash |
| 91 | + header="${header//\{\{NAV_MYNEWPAGE\}\}/}" |
| 92 | + ``` |
| 93 | + |
| 94 | +4. **Build and check**: |
| 95 | + |
| 96 | + ```bash |
| 97 | + ./build.sh |
| 98 | + open mynewpage.html |
| 99 | + ``` |
| 100 | + |
| 101 | +The build is fast enough (milliseconds) that there's no watch mode — just re-run `./build.sh`. |
| 102 | + |
| 103 | +## Available CSS classes |
| 104 | + |
| 105 | +The header bundles a small in-house framework — no Tailwind, no external CSS. See `_pages/_template.html` for a live cheat-sheet covering: |
| 106 | + |
| 107 | +- **Layout** — `.grid` / `.grid-2` / `.grid-3` / `.grid-4` |
| 108 | +- **Components** — `.card`, `.card-gold`, `.alert .alert-info|alert-warning|alert-success`, `.badge .badge-gold|badge-blue` |
| 109 | +- **Interactive** — `.card-link`, `.card-arrow`, `.feature-icon`, `.hero` |
| 110 | +- **Typography** — `h1`–`h3` styled defaults, `code`, `pre`, `table` |
| 111 | + |
| 112 | +## Deployment |
| 113 | + |
| 114 | +GitHub Pages runs `./build.sh` on every push to `main` that touches `docs/**` and publishes the output. The workflow lives at `.github/workflows/pages.yml`. |
| 115 | + |
| 116 | +## Why Bash instead of Jekyll/Hugo/etc? |
| 117 | + |
| 118 | +1. **Tiny footprint** — Bash + Node, no plugin ecosystem to keep alive. |
| 119 | +2. **Runs anywhere** — laptop, WSL, GitHub Actions runner. |
| 120 | +3. **Easy to read** — `build.sh` is ~100 lines of plain shell. |
| 121 | +4. **Fast** — full rebuild in milliseconds. |
| 122 | +5. **GitHub Pages native** — no custom build action required beyond `bash`. |
0 commit comments