Styles and templates
A style gives the look of a site. The key style of the site file names a built-in style or a folder of the site. Flight Manual has two built-in styles:
| Style | The look |
|---|---|
modern |
The default: a menu at the left, the table of contents at the right, and a light and a dark theme that follow the system. |
beetlebug |
The look of the docs sites of ztcl and ztk: warm paper, ink, and one accent color, with a button for the theme (Auto, Light, or Dark) and the menu of the beetlebug projects. The fonts are Inter and IBM Plex Mono when the system has them. |
A style folder has:
page.html: the template of the body of each page.head.html: more lines for the<head>of each page. It is optional.- Each other file, such as a style sheet or a picture. The build copies these files to
assets/of the output, with their paths in the style folder. Each.cssfile at the top of the style folder gets a<link rel="stylesheet">in each page, in the order of the names. favicon.svg,favicon.png, orfavicon.ico: the icon of the site. Each page gets a<link rel="icon">to the first of them in the order of the names. The keyiconsof the site file replaces it. With no icon, a browser asks the server for/favicon.ico.
A template that the style does not have comes from the style modern.
The page
Flight Manual writes the start of each page outside the templates: <html lang>, the character set, the viewport, the <title>, the meta description, the canonical link, the link to the icon, and the links to the style sheets. Then it writes head.html, and then the body from page.html.
The slots
A template is HTML with slots, such as {{title}}. A slot has no logic. The build puts the value of each slot in its place. A slot with a name that is not in this table is an error.
| Slot | Value |
|---|---|
{{content}} |
The HTML of the page. |
{{title}} |
The title of the page: its first heading, or the title of the site. |
{{site}} |
The title of the site. |
{{root}} |
The relative link to the top of the site, such as ../. It is empty on a page at the top. |
{{nav}} |
The menu (below). |
{{toc}} |
The table of contents of the page: a <nav class="toc" aria-label="On this page"> with the headings of level 2, each with its headings of level 3. It is empty on a page with less than two such headings. |
{{pager}} |
The links to the previous and the next page of the list: a <nav class="pager"> with <a class="prev" rel="prev"> and <a class="next" rel="next">. Each link has a <span> with the word Previous or Next, then the label of the page. |
{{logo}} |
The logo of the key logo: an <img class="mark" alt=""> before the name, or empty with no logo. |
{{search}} |
The search form: a <form class="search" role="search"> with a field that sends the query to the search page. It is empty with search 0. |
{{lang}} |
The value of the key lang. |
{{url}} |
The full URL of the page. |
The menu
The menu has the pages of the list in their order. The pages before the first group are a <ul>. Each group is a <details> element with the name of the group in its <summary> and its pages in a <ul>. The group of the current page is open. A group with the name GROUP/PART is a part of GROUP: its pages are in the <details> of GROUP, after a <p class="part"> with the name PART. The link of the current page has aria-current="page". The menu needs no script.
The content
The build changes the HTML of ztcl::markdown in these places:
- Each head cell of a table is
<th scope="col">, and each table is in a<div class="table">, so a wide table can scroll. - A quote that starts with
[!NOTE],[!TIP],[!IMPORTANT],[!WARNING], or[!CAUTION], as on GitHub, is<blockquote class="alert KIND">, with a<p class="alert-title">that has the kind as a word, such as Note. - A fenced code block in Tcl (
tcl), the shell (sh,bash,shell,console, orzsh), Zig (zig), or JSON (json) has its tokens in<span>elements with a class:tok-ca comment,tok-sa string,tok-ka keyword,tok-na number or a literal,tok-va variable or a builtin of Zig, andtok-pthe key of a JSON object. A block in another language has no spans.
The colors
The style sheet of modern has its colors in custom properties of :root, and a second set in @media (prefers-color-scheme: dark). So a page has a light and a dark theme with no script. tools/contrast.tcl checks each pair of a text color and its background in both themes: 4.5 to 1 or more for text, and 3 to 1 or more for the focus ring and the lines of the admonitions (WCAG 2.2 AA). It checks these properties when a style sheet has them:
| Text | Background |
|---|---|
--text, --muted, --link |
--bg |
--code-text, --text, --muted, --link, and the token colors --tok-c, --tok-s, --tok-k, --tok-n, --tok-v, --tok-p |
--code-bg |
--text, --link |
--note-bg, --warn-bg |
--focus, --note-line, --warn-line (3 to 1) |
--bg |
ztcl --allow file,channels --tclsh tools/contrast.tcl styles/modern/site.css
The rules of the page template
A page template must keep these rules. The build gives an error for each rule that page.html breaks:
- The slot
{{content}}is in a<main>element with anid. - A
<nav>element has a name (aria-label). - The first link of the template goes to the
<main>element:href="#ID"with theidof<main>.
The build also writes each head cell of a table as <th scope="col">.
Example
examples/style has a style folder with page.html, head.html, site.css, and favicon.svg. Its templates use each slot. Examples has a picture of it.
Next: Search.