Custom pages
Files in src/pages/ are regular Astro pages. They keep their own layouts,
styles and metadata; JAAD options affect only documentation below routeBase.
The site template creates a local layout and landing page, then mounts the
documentation at /docs:
npm create @jaamd@latest my-site -- --template site
pnpm create @jaamd@latest my-site --template site
yarn create @jaamd my-site --template site
bunx @jaamd/create@latest my-site --template site
src/
layouts/SiteLayout.astro
pages/index.astro
styles/site.css
utils/base.ts
public/
favicon.svg
docs/
01-introduction.md
tsconfig.json
utils/base.ts exports withBase(), which applies Astro’s deployment base to
a root-relative href. Use it for every link the layout writes, so the site keeps
working when it moves to a subpath.
Use the generated layout for other application pages:
---
import SiteLayout from '../layouts/SiteLayout.astro'
---
<SiteLayout pageTitle="Pricing">
<h1>Pricing</h1>
</SiteLayout>
A page of yours on a route of the docs stops the build: see
routeBase.
Sharing the theme with your own pages
A layout of your own does not load JAAD’s theme. Two values keep both halves of a site in step:
| What | Value |
|---|---|
Class on <html> in dark |
dark |
| Stored preference | localStorage["theme"] |
| Stored values | "dark" / "light" |
| No stored value | follow prefers-color-scheme |
Apply the class in the <head>, before anything paints. A browser that blocks
the site’s storage throws on localStorage; the system’s choice then applies:
<script is:inline>
;(function () {
var t = null
try {
t = localStorage.getItem('theme')
} catch (e) {}
var dark = t === 'dark' || (!t && matchMedia('(prefers-color-scheme: dark)').matches)
document.documentElement.classList.toggle('dark', dark)
})()
</script>
Write "dark" or "light" to that key from your own switcher. JAAD reads it
again on the next documentation page. For the colours themselves, see
Colour tokens.
Keeping JAAD’s header and footer
For a page beside docs at the root, such as a changelog, use JAAD’s header and footer instead of a layout of your own:
---
import Page from '@jaamd/jaad/layouts/Page.astro'
---
<Page title="Changelog">
<h1>Changelog</h1>
</Page>
It renders the documentation header and footer, the theme, and your
configuration’s title, navigation and social links around whatever you put
inside. title and description set the metadata for the page; bare drops
the default spacing when the content needs the full width; class is added to
the body.
Search comes with the header, as its icon. There is no sidebar and no table of contents: the page has no place in the documentation’s navigation. To restructure documentation pages themselves, use Advanced layout.
Matching the documentation’s layout
.site-chrome: the column of the header’s content, shared by the footer:--site-chrome-widthless the side gutters..site-main: vertical margin and horizontal padding of the main landmark.bareswaps it for.site-main-bare, which has none.- Layout tokens (
--site-content-width,--site-page-padding, …) are listed in Styles.
<Page title="Changelog">
<div class="site-chrome">…</div>
</Page>
Tailwind
With tailwind: true, utilities on
Page pages use JAAD’s tokens.