Blocks that read a document

v0.0.1

Four blocks of the document kit read a document from the page's URL and draw one part of it: doc-section draws a page, doc-sidebar the contents, doc-toc the headings of the page being read, and doc-switcher the document's versions. Each is a CMS component installed per site. This reference lists their attributes, defaults and behavior. See Show documents on your site for pages built from them.

Attributes the four share

Each block is a live component, so give it an id, as the sample pages do. Every block also takes global HTML attributes through rest, and carries a data-role on each element that a stylesheet can restyle it by. All four take the attributes below, except that doc-toc has no doc_base: it links to anchors in its own page and writes no address of another page.

AttributeTypeDefaultWhat it does
workspacestring""A document's slug, to pin the block to one document. Empty, the block reads the slug from the URL.
pathstring""The address of the document the page serves, such as /product/docs. The block reads that document and its pages under it, not the document a slug in the URL names. A pinned workspace wins over it.
workspace_paramany"workspace"The URL key the document's slug arrives under: a captured segment of the page's path, or a query key.
section_paramany"section"The URL key a page's address arrives under, such as headless/switch held by a *section capture. Nothing under it means the document's own address: the version's front page, else the landing.
version_paramany"v"The URL key a version number arrives under. Nothing under it, or a version the document does not publish, means the latest.
langstring""The language the page is written in. A slug names one edition per site, so this stops a document of one language being drawn inside a page of another. Empty, the slug decides.
lang_paramany"lang"The query key the language travels under. A reader's ?lang= replaces lang, and the links a block writes carry the key onward. Leave it empty on a site whose language is a path segment, and on a documentation path that names no language.
paramsany{}The page's own URL keys, its query string and captured segments, handed straight through.
doc_baseany"/docs"Where documents with no address of their own live. Write the language into it as :lang on a site whose language is a path segment. A document with an address is linked there instead. Not on doc-toc.
page_sourceanynilThe rows the page read for this address, handed down by the page as page_source={assigns[:page_source]}. The block takes from it the rows that match exactly what it would read itself, for the same reader, and reads anything else itself, as it does without it.
current_useranynilThe signed-in reader, handed down by the page. A record locked to permissions the reader does not hold is left out. With no reader, every locked record is.

A page that shows a document or a page of one reads the document, its versions and the page once, and hands those rows to its blocks. These four blocks are the ones that take them. doc-workspace-list and doc-section-cards declare no page_source and always read for themselves. See Page source: read a page's rows once for how a page reads and hands down the rows.

The tables below list only what each block adds. Every block that reads in the background also takes loading_text, error_text and retry_text, listed in its own table. While a later read runs, the block draws a skeleton. When a read fails it draws the error text and a Try again button.

doc-section

Draws one page of a document: the trail above it, its title, when it last changed, its text, its notes, and links to the pages either side. With nothing asked, it draws the version's front page, or the document's landing. The landing is an overview: the document's tile, its version and number of pages, its name and summary, the first pages as numbered cards, and every page under the heading it is filed under. The block reads in step with the request, so the page's text is in the HTTP response.

AttributeTypeDefaultWhat it does
show_breadcrumbbooleantrueDraws the trail of parent pages above the title.
crumb_currentbooleanfalseEnds the trail with the page itself, so a page at the top of its document has a trail too.
show_versionbooleantrueDraws the version the page was last changed in, on the line above its title.
show_updatedbooleantrueDraws when the page last changed and the version being read, as in Updated Oct 14, 2026 · v1.2.0.
show_notesbooleantrueDraws the page's notes after its text.
show_pagerbooleantrueDraws the links to the pages either side.
start_countinteger3How many pages the landing draws as numbered cards at its top, each with the start of its text, in reading order, from 0 to 6. 0 draws none.
code_linesinteger16A code block of more lines is cut at this many, with a button that shows all of it. Allowed: 0 (never cut), 8, 12, 16, 20, 24, 32.
tab_paramany"tab"The URL key a tab added by a plugin travels under. ?tab=props opens a tab named props.
pending_waitinteger120000How many milliseconds a tab whose data a plugin is still fetching waits before it says the data could not be had.

The words doc-section says are attributes too:

AttributeDefaultWhere it appears
updated_text"Updated %{date}"Before the version in the updated line. %{date} is the date in the page's language.
previous_text"Previous"The step back.
next_text"Next"The step forward.
idle_text"Choose a document."When the URL names no document.
missing_text"That page is not published."When the document or the page a link names is not there.
empty_text"This document has no published pages yet."When the version has nothing approved.
pages_text"%{count} pages"The page count on the landing. %{count} is the number.
one_page_text"%{count} page"The page count of a document with one page.
copy_text"Copy"The copy button of each code block.
copied_text"Copied"The same button for a moment after it copied, and what a screen reader hears.
copy_label"Copy code"The copy button's name for a screen reader.
expand_text"Show all %{count} lines"The button under a cut code block. %{count} is its number of lines.
collapse_text"Show less"That button once the whole block is shown.
docs_tab_text"Documentation"The tab holding the page's own text, drawn when a plugin adds tabs.
tabs_label"Sections of this page"The tab bar's name for a screen reader.

The page's text and notes pass through the same HTML cleaning as the text is stored through, then draw the components placed in them. Each code block is drawn in a window with its language and a copy button. A placed doc-callout, doc-example or doc-section-cards is drawn there. See Callouts, examples and the version placeholder. A plugin adds facts and tabs through the document:page:extras event. See Plugin events.

doc-sidebar

Draws a document's whole contents as a tree, with the branch the reader is in open. Its hook doc-sidebar-scroll keeps the list where the reader left it as they move between pages, and brings the current entry into view when it lies outside.

AttributeTypeDefaultWhat it does
headingstring"Contents"The words above the list. Empty, none are drawn.
show_filterbooleanfalseDraws a box that narrows the list to the entries whose title holds what the reader typed. It narrows what the block already holds, so a keystroke reads nothing.
expand_allbooleanfalseDraws every nested page at once. Off, only the branch the reader is in is open.
link_clickanynilA JS command run when a page in the contents is pressed, before the page is drawn. JS.exec("phx-remove", to: "#drawer") closes a drawer the contents sit in. Empty, a press runs nothing of its own.
filter_textstring"Filter pages"What the empty filter box says.
empty_textstring"No published pages."When the version has nothing approved.
none_textstring"Nothing matches."When the filter leaves no entry.
loading_textstring"Loading the contents…"What a screen reader hears while the read runs.
error_textstring"The contents could not be loaded."When the read fails.
retry_textstring"Try again"The way out of a failed read.

doc-toc

Draws what is on the page being read, its headings and its notes, as links to anchors in the page. On a document's landing, which has no text, it draws nothing.

AttributeTypeDefaultWhat it does
headingstring"On this page"The words above the list. Empty, none are drawn.
show_headingsbooleantrueLists the headings inside the page's own text.
show_notesbooleantrueLists the notes of the page.
min_entriesinteger2How many entries it takes before the list is drawn, from 1 to 20. Under that, nothing is drawn.
loading_textstring"Loading this page's contents…"What a screen reader hears while the read runs.
error_textstring"This page's contents could not be listed."When the read fails.
retry_textstring"Try again"The way out of a failed read.

doc-switcher

Draws a document's versions in a menu, each leading to the same page in that version. A version that does not have the page, or whose copy of it the reader may not open, leads to the document's front page. The closed menu names the version being read, and the list marks each version that is not stable with its status. When the version being read is not the latest, a line beside the menu says so and links to the latest. The block has no language switch: the site's header lists the languages the page is written in. On the sample pages, the bar under the header draws it. See Page frame: languages and the section bar.

AttributeTypeDefaultWhat it does
show_bannerbooleantrueDraws the line beside the menu that tells a reader the version being read is not the latest.
version_textstring"Version"What the version menu is called. Empty, it shows the version number alone, as v0.0.6.
latest_textstring"latest"The badge on the newest version, and the word after the version in the closed menu while the newest is being read.
banner_textstring"You are reading an older version of this document."What a reader on an older version is told.
banner_link_textstring"Read the latest"The link out of an older version.
loading_textstring"Loading the other versions…"What a screen reader hears while the read runs.
error_textstring"The other versions could not be loaded."When the read fails.
retry_textstring"Try again"The way out of a failed read.