@casoon/pages-theme
v0.23.2
Published
Shared Astro theme for the GitHub Pages sites of CASOON open-source projects
Maintainers
Readme
@casoon/pages-theme
Shared Astro theme for the GitHub Pages sites of CASOON open-source projects: one layout, one set of tokens and components, and generated routes for docs, showcase, changelog and 404. Projects supply content, examples and configuration.
Project layout
<repo>/
├── site/ # Astro project (this theme as dependency)
│ ├── astro.config.mjs # casoonPages({ … })
│ └── src/
│ ├── pages/index.astro # start page, composed from theme components
│ ├── showcase.ts # exports `examples`
│ ├── use-cases.ts # exports `useCases` (optional)
│ └── content.config.ts # docs collection
├── docs/ # Markdown / MDX, versioned with the code
├── examples/ # fixtures, shared with the test suite
├── CHANGELOG.md # Keep a Changelog
└── .github/workflows/pages.ymlInstall
pnpm add @casoon/pages-themeRequires Astro 7.3 or newer (peer dependency). The package ships its TypeScript and Astro sources; Astro compiles them with the site.
Releases are published from the GitHub Actions workflow of casoon/pages-theme via npm trusted
publishing, never from a developer machine, and carry signed build provenance. To check an
installed copy:
npm audit signaturesSetup
// site/astro.config.mjs
import casoonPages from '@casoon/pages-theme';
import { defineConfig } from 'astro/config';
export default defineConfig({
site: 'https://casoon.github.io/runemark',
base: '/runemark/',
integrations: [
casoonPages({
name: 'runemark',
description: 'Renders ANSI terminal output as accessible, script-free HTML.',
repo: 'casoon/runemark',
version: '0.4.2',
packages: [{ label: 'crates.io', href: 'https://crates.io/crates/runemark' }],
docsGroups: { 'getting-started': 'Getting started', reference: 'Reference' },
}),
],
});// site/src/content.config.ts
import { docsCollection } from '@casoon/pages-theme/content';
export const collections = { docs: docsCollection() };Options
| Option | Default | Purpose |
| --- | --- | --- |
| name, description, repo | – | Header, meta tags, GitHub links, JSON-LD |
| tagline | – | A few words for the start page's <title> and the OG image; see „Search engines" |
| website | – | The project's landing page (https://example.com): header, JSON-LD sameAs |
| catalog | repository name | Deprecated, no longer linked; kept so existing configs still build |
| version | the project's manifest | Header badge, "Docs for vX"; see „Version" |
| license | MIT | SPDX id for footer and JSON-LD; false for proprietary code names no licence, and the OG image and Hero read "CASOON" instead of "CASOON Open Source" |
| branch | main | "Edit this page" links |
| accent | CASOON petrol | { light, dark } project colour; needs 4.5:1 on #f4f1eb and #151412 |
| favicon | CASOON favicon | { svg?, ico?, appleTouch? }, paths in the project's public/; each one optional |
| logo | project name as text | { light, dark, alt?, height? }, paths in public/; the header shows the image of the active theme instead of the name |
| ogImage | generated og.png | path in public/ (1200 × 630); set, the theme writes no og.png and og:image points to the file |
| packages | [] | Registry and API-doc links in the footer |
| docsGroups | {} | Sidebar groups: folder in docs/ → label, in order. Root pages join the first group |
| changelog | ../CHANGELOG.md | Path relative to site/, or false |
| showcase | ./src/showcase.ts | Module exporting examples: ShowcaseExample[], or false |
| showcaseLayout | list | Showcase overview: list (every example in turn) or explorer; see „Showcase explorer" |
| useCases | ./src/use-cases.ts if it exists | Module exporting useCases: UseCase[] (and optionally lead, tradeoffs), or false; see „Use cases" |
| demo | false | Header label of a live demo page; the project supplies src/pages/demo.astro |
| nav | [] | Further header entries after the theme's own: { label, href } with an absolute https:// URL, e.g. a related site |
| mdxComponents | – | Module exporting components for docs MDX, next to the theme's; see „Docs frontmatter" |
| lang | en | en or de: <html lang> and the theme's own UI strings (lib/i18n.ts); props passed by the project win. One page can differ (a translated start page): <Base lang="de" alternates={[…]}> sets <html lang>, hreflang links and the header switch, and every theme component on that page uses its strings |
| showcaseLead | – | Lead paragraph of the showcase overview, instead of the theme's generic one |
Version
Left out, version comes from the manifest next to site/: version in package.json, else
[package] or [workspace.package] in Cargo.toml. So the number is maintained in one place,
and a release updates the site by itself. Pages read it as config.version from
virtual:casoon-pages/config — a start page that shows the release in a Badge takes it from
there instead of typing it out.
A wrong number is worse than none, so anything that cannot be read with certainty yields none:
a workspace whose version sits in a member crate, a package.json without version, a project
with neither manifest. Those pass version themselves, and false shows none at all.
Routes
| Route | Source |
| --- | --- |
| / | the project's src/pages/index.astro |
| /docs/… | docs/**/*.{md,mdx}; docs/index.mdx becomes /docs/ (an entry page with StepPath and LinkList) |
| /use-cases/ | useCases from the use-cases module, linked first in the header |
| /showcase/, /showcase/<slug>/ | examples from the showcase module, labelled "Examples" |
| /changelog/ | CHANGELOG.md (## [x.y.z] - YYYY-MM-DD, ### Added …, ### Breaking) |
| /demo/ | the project's src/pages/demo.astro, linked once demo is set |
| /404 | theme |
| /sitemap.xml, /og.png | written after the build when site is set; see „Search engines" |
Docs frontmatter
title (required), description (lead paragraph), order (position in its group),
sidebarLabel.
MDX pages use theme components without importing them. docs/ sits outside site/ and
cannot resolve packages, so the docs route provides all components. A project adds its own
with mdxComponents: './src/mdx-components.ts' — a module exporting
components = { Name: Component } — for anything only the site can build, such as a
component rendering the project's own output. Its names win over the theme's. Write links between docs
pages relative (../quickstart/), because the base path differs per project.
Components
Import from @casoon/pages-theme/components in .astro files; available directly in MDX.
| Component | Use |
| --- | --- |
| Hero | Title, lead, default slot (install, badges), output slot (real output), caption slot (one line under it, split layout); layout, command, tone and bleed pick the variant |
| AnchorGrid | Card grid under the hero, each linking to a section further down or out to a doc |
| Install | Install command per ecosystem, CSS-only tabs, copy button; long commands wrap at spaces and after a / |
| Badge, Badges | Static badges (no external badge services); tone solid, soft or muted marks result classes |
| Facts | Verifiable key figures; layout="grid" (tiles) or "list" (spec sheet) |
| Features | Core points; layout="numbered" (3–5 items) or "grid" (an icon-tile catalog) |
| Spotlight | Repeatable two-column feature section — eyebrow, title, lead, bullets, links, beside a media slot |
| StatBand | Key figures as one row with hairlines, under the hero; the lighter sibling of Facts layout="grid"; four items stay four, two by two or one column, never 3 + 1 |
| Tour | Presentation of three to five steps beside one stage; one named slot per step (step-1 …) with a Terminal, CodeBlock or Figure; CSS-only |
| UseCases | Use cases on the start page: linked rows of title, sentence, tags and an arrow |
| SectionIntro | Section head: h2 left, a placing paragraph right |
| Split | Repeatable open row: text with index, note, ticked or numbered points and links beside a medium; reverse swaps sides, align="start" tops text and a tall medium |
| FlowPanel | A branch as a medium for Split: one start, two to four ways, one result |
| BarCompare | Measurements as pairs of bars, every value also as text; facts as a grid (2, 3, 4, 6) or rows (other counts); default slot is the footnote |
| ElementList | Term in mono plus explanation, as rows between hairlines (<dl>) |
| Showcase | Dark panel (dark in both themes) with a large image or video |
| Compare | Comparison <table> of two to four columns ({ title, label?, badge? }), highlight raises one, a one-cell row spans all; a list per topic under 700 px |
| AudienceList | Editorial list: heading left, term + text rows right (<dl>) |
| Tradeoffs | Lowered panel for honest limits |
| Section | Neutral section frame: heading, lead, slot, links, width (narrow, default, wide); the theme's spacing |
| LinkRow | A row of text links with an arrow, the quiet way on from a section; Split and Section use it for links |
| LinkList | Linked rows of title, sentence and arrow between hairlines; group fills it from a folder in docs/, layout="cards" sets short links with a tag as cards |
| StepPath | A reading path of a few numbered, linked steps in one sand band, for the docs entry page |
| Figure | Image or drawing (default slot) in a frame with title and caption, ground="sand" for a diagram; fills its container (full section width, or the medium of a Split); zoom opens the image at full size on click (popover, no script) |
| VideoEmbed | YouTube video as a facade: a local poster with a play mark, linked to the video (and list) on YouTube; no request to YouTube until the visitor follows the link, no script; fills its container like Figure |
| SpecList | Term/value rows over the full width between hairlines (<dl>), for the data sheet of a page |
| Flow | 3–5 stages from input to result, each with its artifact (index.md, dist/) in a mono chip |
| Integrations | Grid of what the project plugs into: icon tile, name, category |
| FileSet | The files a run produced: tabs, grid or rail view |
| BuildOutput | One real build output on the start page |
| Quickstart | Steps, docs link, code slot |
| Keymap | Keyboard shortcuts or CLI flags, grouped cards of label + <kbd> keys |
| ReleaseHighlights | Teaser of one changelog release on the start page |
| Faq | Native <details> accordion, no JS |
| CodeBlock | Build-time highlighting (Shiki, theme-aware), copy button; marks sets numbered dots at line ends to go with Split numbered; wrap wraps long lines |
| Terminal | ansi prop (converted at build time) or pre-rendered HTML as slot |
| Callout | note, tip, caution, deprecated |
| Tabs | CSS-only tabs, one named slot per tab id; bare drops the panel frame for scenes and screenshots |
| ApiEntry | API overview entry; item-level docs stay on docs.rs / TypeDoc |
| Swatch | Colour token preview |
| ExamplePanel | Input next to output; used by the showcase routes |
| Demo | Stage for the project running live in the page; see „Live demo" |
Start-page widths are two tokens: --max (1100 px) for reading-width blocks and --max-wide
(1240 px, inner padding --gutter) for Hero, Split, Spotlight, Showcase, Tradeoffs and
Section width="wide", so their text edge lines up. Drawings take --diagram-node,
--diagram-line and --diagram-accent (derived from --ink, --border-strong and --accent)
and --heading for text, so they follow the theme.
Section components share one rhythm: the space below each is --section-y, and the heading is
--h-section or, with size="sub", the smaller --h-sub.
@casoon/pages-theme/ansi exports ansiToHtml and escapeAnsi for projects without their
own renderer. ansiToHtml renders the 16-colour palette as classes (so the theme's colours
apply) and 256-colour and 24-bit colour — foreground and background — as inline styles. @casoon/pages-theme/layouts/Base.astro wraps custom pages in the frame; layouts/Page.astro adds a plain content page on top of it (breadcrumb, title, lead, width, body set like the docs); and
@casoon/pages-theme/url exports url() — a project page that links or loads something
site-internal needs it, because the base path changes per project.
Hero variants
Hero carries four start-page openings. All of them use the same props; layout, command
and tone decide which one, and what goes into the slots decides the rest. The output
slot takes the project's real output — a Terminal, or FileSet when the project writes
files.
| Variant | Hero | output slot |
| --- | --- | --- |
| Artefacts | layout="split" (default) | FileSet view="grid" — one card per file |
| Pipeline | layout="stack" command="<cmd>" plus a source slot | FileSet view="tabs" — one pane per file |
| Colour field | tone="invert" on any layout | Terminal, or whatever the project shows |
| Editorial | layout="editorial" | FileSet view="rail" — names and one line each; with bleed the output runs down out of the hero (no bottom padding, corners or border, a 72 px fade into --surface) |
The split layout sets the title across the full width, then the text column and the output at
about 38 : 62 from 760 px up; below that they stack. A Terminal in the output scales its
padding and font size with the viewport, so a 37-column line fits at 390 px.
The stack layout reads as a pipeline from top to bottom: the source slot (usually a
CodeBlock with the configuration), the command pill, then the output — each over the full
width of the container. Side by side the three do not fit inside --max: the source is cut off
mid-line and the file names wrap to a second row. Without a source slot the band is just the
output.
FileSet takes files — id, name and optional path, size, note — and one named slot
per id holding that file's content, the same way Tabs does. The rail view needs no slots.
The tab strip stays on one row at every width: below 640 px the names lose their suffix
(robots.txt → robots, and only when the stems stay distinct), and a strip that still does not
fit scrolls sideways. Each pane scrolls on its own for long lines.
tone="invert" redefines the colour tokens inside the hero, so Install, Badges and
FileSet follow without knowing about it. The ground is --invert-bg with --invert-accent,
the same in both colour schemes.
Showcase descriptions
description is plain text with one piece of markup: `backtick spans` become inline
code on the detail page and the overview cards, styled like inline code in the docs. Everything
else is escaped, so a description cannot inject HTML. In the meta description the backticks are
dropped. Descriptions without backticks render as before.
Large showcases
A showcase with many examples gets two optional fields per ShowcaseExample:
group: the heading the example is listed under. Examples of one group appear together, groups in the order of their first example, with a jump list at the top of the overview.preview: HTML for a small preview, typically a lazily loaded image. An example with a preview appears on the overview as a card (title, description, preview, link to the detail page); input and output stay on the detail page. Without it the overview shows the full panel as before.
Use cases
A site with src/use-cases.ts (or another module named by useCases) gets the page
/use-cases/ and a "Use cases" entry first in the header. The module exports
useCases: UseCase[] (type from @casoon/pages-theme/use-cases): slug (the anchor), title,
body, and optionally eyebrow, tags, steps, code (with marks matching the steps),
specs and links. The first use case with steps or code is set as a sand panel with the
code block beside its numbered steps; the others follow as open rows with their specs beside
the text. Optional exports: lead beside the page title, and tradeoffs (the props of
Tradeoffs) as a closing panel. On the start page, UseCases lists them as linked rows.
Showcase explorer
With showcaseLayout: 'explorer' the overview shows a rail of the examples under their group
headings beside one selected example, with up to three tabs: Output (the rendered result beside
notes), Source (the input beside output.source, the produced markup as text) and How to
(steps). A tab without data is left out. Below 860 px the rail becomes a row of chips. It
works without a script; the detail pages stay. Suits a handful of examples; a large showcase
keeps the list.
Live demo
The showcase shows what a package produced at build time. A demo shows the package itself, running in the visitor's browser — for projects whose point only becomes visible in motion.
Set demo: '<label>' for the header entry and write site/src/pages/demo.astro; the theme
injects no route, so the page is the project's own. Wrap the running instance in the Demo
component and put everything it needs, including its <script is:inline>, in the default
slot.
The component marks its stage data-demo, and that mark carries two exceptions from the
rules below — nowhere else on the site:
- The demo's own scripts live inside the stage. Outside it, the two inline scripts stay the limit.
check-site.cjsexcludes the stage from axe. A demo may deliberately exhibit what the project reports on; a broken form inside the stage is the exhibit, not a defect of the page.
Everything else still holds, the origin rule above all: a demo loads its code from the site itself. One that needs a CDN cannot ship here.
Search engines
Each page gets canonical URL, meta description, Open Graph and twitter:card
(summary_large_image), and JSON-LD SoftwareSourceCode with url, codeRepository, sameAs
(website and the packages links) and CASOON as author and publisher. All of it needs site
in astro.config.mjs.
- Title: the start page is
<name> – <tagline> | CASOON, other pages<page> · <name>. Withouttaglinethe start page is<name> | CASOON. Keep the tagline to a few words, so the title stays under about 60 characters;descriptionremains the meta description. - OG image:
og.png(1200×630) is rendered at build time from name, tagline, description and address, in the theme's fonts on the light sand ground, with a short rule and the address in petrol (the project's lightaccentwhen set). - Sitemap:
sitemap.xmllists every built page except 404, linked from the head. A project that writes its own —@casoon/astro-site-filesdoes — keeps it: the theme skips the file when it already exists. That works only when the project's integration is listed beforecasoonPages()inastro.config.mjs, because the hooks run in that order. - Links out: the header shows
websiteafter its links; the footer links the catalog on casoon.dev, in the page'slang.
The root https://casoon.github.io/ comes from the repository casoon/casoon.github.io: an
overview of the project sites, the only robots.txt crawlers read for the domain (one Sitemap:
line per project), and the Google Search Console verification. Its URL-prefix property
https://casoon.github.io/ covers every project site, so a project needs no property and no
verification file of its own. For a new site:
- Deploy it and check that
https://casoon.github.io/<repo>/sitemap.xmlanswers 200. - In
casoon/casoon.github.io, addSitemap: https://casoon.github.io/<repo>/sitemap.xmltorobots.txtand the site toindex.html, then push. - In the property
https://casoon.github.io/, Sitemaps → submit<repo>/sitemap.xml.
Never set a custom domain on casoon/casoon.github.io: GitHub would redirect every project site
to it as well.
Rules the theme enforces
- No external requests: fonts are bundled (Inter, Onest, JetBrains Mono, Latin subset; licence
in
fonts/OFL.txt), no CDNs, embeds, analytics or cookies. - JavaScript: two small inline scripts (theme before first paint; theme toggle and copy
buttons). Tabs,
Tourand the showcase explorer work without JavaScript. The one exception is aDemostage, see above. - Footer on every page, in the site's language (
lang): name and description, GitHub andpackagesas pills, "A CASOON project · Jörn Seidel", licence, the project catalog on casoon.dev, imprint and privacy policy (casoon.de). - Light and dark theme, following
prefers-color-schemeuntil the visitor chooses.
Maintaining
Development, releases, the rollout to all project sites and setting up a new one: MAINTAINING.md.
