ArticleLayout
The page a post reads in, as pieces a caller arranges.
Article
Making the build remember
What a content-keyed cache keeps between runs, and how to pick its keys.
Contents
Why a slower build
The first build after a clean checkout took four minutes. Most of that time went to work the last build had already done, so the question was what to keep between runs.
What the cache keeps
The cache keeps each step's output under a key made from its inputs. A step whose inputs have not changed copies its output back instead of running again.
Choosing the keys
A key that leaves out an input serves stale output; a key that includes too much never hits. The lock file, the step's own source and its flags were enough.
Afterwards
A build with nothing changed now replays in under a second, and a one-file change rebuilds only the steps that file feeds.
View code
<ArticleLayout
outline={[
{ id: "why", text: "Why a slower build", level: 2 },
{ id: "cache", text: "What the cache keeps", level: 2 },
{ id: "keys", text: "Choosing the keys", level: 3 },
{ id: "after", text: "Afterwards", level: 2 },
]}
>
<ArticleLayout.Header>
<p>Article</p>
<h1>Making the build remember</h1>
<p>What a content-keyed cache keeps between runs, and how to pick its keys.</p>
</ArticleLayout.Header>
<ArticleLayout.Bar>Contents</ArticleLayout.Bar>
<ArticleLayout.Body>
<Typeset preset="reading">{body}</Typeset>
</ArticleLayout.Body>
<ArticleLayout.Footer>
<AuthorCard>
<AuthorCard.Portrait initials="MH" />
<AuthorCard.Details>
<AuthorCard.Name href="/about">Maren Holt</AuthorCard.Name>
<AuthorCard.Subtitle>Editor</AuthorCard.Subtitle>
</AuthorCard.Details>
</AuthorCard>
</ArticleLayout.Footer>
<ArticleLayout.Rail>
<ArticleLayout.Outline />
</ArticleLayout.Rail>
</ArticleLayout>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { ArticleLayout } from "@sdxc/ui/blog";Renders the post as an <article> grid: the reading column holds .Header, .Bar,
.Body and .Footer in the order written, 2rem apart; a .Rail takes a sticky column
beside it from a 60rem layout and hides below that, where .Bar shows instead. Load
@sdxc/ui/table-of-contents in the browser entry for the outline's marker.
Composition
The parts the component publishes, each a static property of the host.
ArticleLayoutArticleLayout.HeaderThe post's title block (kind, title, lead, byline) in a<header>, in the reading column or spanning the rail too withspan="full", where it always sits first, 2.5rem above the rest.ArticleLayout.BarThe outline as a sticky bar in the reading column, shown below the rail width or wherever the layout has no rail; it draws nothing when the outline is under its minimum.ArticleLayout.BodyThe post's body in the reading column.ArticleLayout.FooterWhat closes the post, such as tags, the author and its neighbours, in a<footer>in the reading column.ArticleLayout.RailThe sticky column beside the reading column from the rail width, stacking what it holds (an.Outline, the terms a post uses) 2rem apart and scrolling on its own when taller than the screen.ArticleLayout.OutlineThe outline as a list of the body's headings with a marker on the one being read, for the rail; it draws nothing when the outline is under its minimum.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
outline | TableOfContents.Item[] | — | No | The body's own headings, which .Bar and .Outline list. |
outlineMinItems | number | — | No | Fewest headings that earn an outline; below it .Bar and .Outline draw nothing. @default 2 |
measure | string | — | No | The reading column's widest extent. @default "42rem" |
stickyTop | string | — | No | The height of a site header kept on screen above the layout, so the bar, the rail and jumped-to headings sit below it. |
Also accepts everything in TagProps<"div">.
ArticleLayout.Header
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
span | "column" | "full" | — | No | column sets the header in the reading column, level with the rail; full spans it across the column and the rail, for a display headline wider than the measure. |
Also accepts everything in TagProps<"header">.
ArticleLayout.Bar
ArticleLayout.Body
Also accepts everything in TagProps<"div">.
ArticleLayout.Footer
Also accepts everything in TagProps<"footer">.
ArticleLayout.Rail
Also accepts everything in TagProps<"div">.
ArticleLayout.Outline
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
children | string | — | No | The outline's visible heading and accessible name. @default "On this page" |
Also accepts everything in Omit<TagProps<"div">, "children">.