Docs menu

Labels and styles

View as Markdown

Labels #

labels replaces any of the words Elysium writes around a page. Set lang beside it, for the lang attribute and the date format:

{
  "lang": "ja",
  "labels": {
    "onThisPage": "ใ“ใฎใƒšใƒผใ‚ธ",
    "previous": "โ† ๅ‰ใธ",
    "next": "ๆฌกใธ โ†’",
    "results": "{count} ไปถ"
  }
}

Elysium fills in {heading} and {count}:

Key Default
docs Docs, the sidebar's label
menu Docs menu
moreDocs More docs, the previous and next links' label
onThisPage On this page
previous, next โ† Previous, Next โ†’
lastUpdated Last updated
viewMarkdown View as Markdown
linkTo Link to {heading}
search, searchDocs Search, Search docs
recent Recent, empty search's visited pages
navigate, open, close navigate, open, close: the search key hints
oneResult, results 1 result, {count} results
noMatches No matches found.
searchFailed Search failed. Try again in a moment.
start Get started โ†’, the top page's link

DEFAULT_LABELS from @memomori-app/elysium/labels holds them all. A template prints one as {{.labels.start}}.

Styles #

docs-site.css is the whole default theme: Charon's page styles, the module styles, docs.css and docs-layout.css.

  • docs.css styles the title row, the sidebar, "On this page", previous and next, and the search dialog, all from the --charon-* tokens.
  • docs-layout.css lays out the three columns and sets the font.
  • fonts.css declares JetBrains Mono, which Elysium ships.

Change colors through the tokens, as on any Charon page. The search dialog takes four tokens of its own, each with a fallback:

Token Used for Fallback
--elysium-surface dialog background --charon-background
--elysium-surface-subtle dialog footer --charon-code-inline-background
--elysium-faint icons and secondary text --charon-captions
--elysium-highlight matched words a pale yellow

To restyle the CLI's site, give it a template that links your own stylesheet after _elysium/docs.css.

Light and dark #

The default theme ships light and dark colors and shows the one the reader's system asks for: docs-layout.css sets color-scheme: light dark on the root, and every color is a light-dark() pair. Code blocks and maps follow it too. When the system states no preference, or the browser is too old for light-dark(), the page is light.

The default template has no theme button. To add one, put it in your own template and have it set color-scheme on the root. A head script applies the saved choice before the page paints:

<head>
  <script>
    try {
      const theme = localStorage.getItem('theme')
      if (theme) document.documentElement.style.colorScheme = theme
    } catch {}
  </script>
  ...
</head>
<body>
  <button type="button" id="theme-button">Toggle theme</button>
  <script>
    document.getElementById('theme-button').addEventListener('click', () => {
      const root = document.documentElement
      const dark = root.style.colorScheme
        ? root.style.colorScheme === 'dark'
        : matchMedia('(prefers-color-scheme: dark)').matches
      const theme = dark ? 'light' : 'dark'
      root.style.colorScheme = theme
      try {
        localStorage.setItem('theme', theme)
      } catch {}
    })
  </script>
  ...
</body>

The MemoMori docs keep theirs in the header above the sidebar.

Font #

The default theme sets every page, code included, in JetBrains Mono. Elysium ships the font: four variable WOFF2 files, Latin and Latin Extended, upright and italic, about 115 KB in all. A browser fetches only the ones a page uses, and nothing loads from a font host. Code turns off the font's ligatures, so ==, ~~ and -> show as typed.

  • elysium build writes them to _elysium/fonts/.
  • The Vite plugin bundles them like any other asset.

To use another font, give font its family and, if the browser needs to fetch it, a stylesheet that declares it:

{
  "font": {
    "family": "'Inter', system-ui, sans-serif",
    "stylesheet": "/fonts/inter.css"
  }
}

Each page links the stylesheet and sets --elysium-font to the family. Both keys are optional. The family goes into the page's CSS as written, so give it as you would in a font-family rule. Under a Content Security Policy without style-src 'unsafe-inline', leave out family and set --elysium-font on :root in the stylesheet itself.

Elysium doesn't fetch the stylesheet or its font files: serve them yourself, or put them in the docs folder. A file there is served under the site's base, so with --base /docs, fonts/inter.css in the docs folder is /docs/fonts/inter.css.

To use JetBrains Mono in your own template, import @memomori-app/elysium/fonts.css and set font-family: 'JetBrains Mono'.

JetBrains Mono is under the SIL Open Font License 1.1; the package's THIRD-PARTY-NOTICES holds the text.