@diso.io

doc @diso.io/doc

Reference

render

RenderedPage One page of a site as markup.
renderPages Every page of a site as markup, the page for unknown addresses included.
renderIndex The site's /llms.txt: its title, its description, and its pages by group, each linked as Markdown when the page has any.
renderSearch The site's search index: every page cut at its headings, each piece as plain text.

RenderedPage

interface RenderedPage

One page of a site as markup.

path: string
title: string The title the browser tab shows.
html: string What goes inside <diso-docs> when this page is the one shown.
markdown?: { path: string; text: string } The page as Markdown and where to serve it, when the page has any.

renderPages

async function renderPages(site: Site): Promise<RenderedPage[]>

Every page of a site as markup, the page for unknown addresses included. Needs no DOM. The markup is what <diso-docs> draws in the page, so a crawler reads the same site a visitor sees.

renderIndex

function renderIndex(site: Site): string

The site's /llms.txt: its title, its description, and its pages by group, each linked as Markdown when the page has any. It is the index a program reads to find the pages, in the form https://llmstxt.org/ gives.

renderSearch

async function renderSearch(site: Site): Promise<SearchEntry[]>

The site's search index: every page cut at its headings, each piece as plain text. The page reads it only when someone searches. Needs no DOM.

shell

docs

function docs(site: Site): void

Define <diso-docs> as this site: its header, navigation, the page for the current address, and the headings on that page. A link to another page of the site, written anywhere inside it, goes there without loading the page again.

docs({ title: "My library", pages: [{ path: "/", ...readme }] });
<diso-docs></diso-docs>

site

Heading A heading inside a page, for the list of what is on it.
Content What a page shows.
Page One page of a site.
Link A link in the site's header, such as its repository.
Group Pages listed together under a title in the site's navigation.
Site A docs site: its pages and groups of pages, in the order they are listed.
SearchEntry One part of a page as search reads it: a heading and the text under it.
pages The pages of a folder, in the order and groups given.

Heading

interface Heading

A heading inside a page, for the list of what is on it.

level: number 2 for <h2>, 3 for <h3>.
text: string
id: string The heading element's id, which a #fragment link goes to.

Content

interface Content

What a page shows.

draw: (title: string) => unknown Returns what the page shows: anything a hype template takes. It is given the page's title, which a Markdown page shows as its top heading.
headings?: Heading[] The headings on the page, listed beside it.
markdown?: string The page as Markdown, served beside it with .md on the end for a reader that is a program. A Markdown file imported as a page carries its own while the site is being built.

Page

interface Page extends Partial<Omit<Content, "markdown">>

One page of a site. What it shows is either on the page itself, as draw, or fetched when the page is first opened, by load. A Markdown file imported as a module gives title, markdown and load.

  • path: string

    Where the page is served, such as / or /guide/install.

  • title: string

  • load?: () => Promise<Content>

    Fetches what the page shows, the first time it is opened. With it, the page's content is not part of what every visitor downloads.

    { path: "/playground", title: "Playground", load: () => import("./playground").then((m) => m.default) }
    
  • markdown?: string | true

    true says the page has Markdown without carrying it: what a Markdown file's page has in the browser.

  • wide?: boolean

    Give the page the full width, with no navigation or headings beside it.

  • unlisted?: boolean

    Leave the page out of the navigation, for one the header links to.

interface Link {
  label: string
  href: string
}

A link in the site's header, such as its repository.

Group

interface Group

Pages listed together under a title in the site's navigation. A group can hold groups, as deep as the site needs.

title: string
link?: Link Shown small beside the title, such as the name of the package the group documents, linked to where it is published.
pages: Array<Page | Group>

Site

interface Site

A docs site: its pages and groups of pages, in the order they are listed.

title: string
description?: string One or two sentences on what the site documents.
pages: Array<Page | Group>
links?: Link[]

SearchEntry

interface SearchEntry

One part of a page as search reads it: a heading and the text under it.

path: string The page's path.
page: string The page's title.
heading: string The heading the text is under, or empty for what comes before the first.
id: string The heading's id, or empty.
text: string

pages

function pages(files: Record<string, unknown>, names: readonly Named[]): Array<Page | Group>

The pages of a folder, in the order and groups given. files is each file's page by its path, as import.meta.glob gives them. A page is named here by its file's path inside the folder, without the extension, and is served there: guide/install.md is guide/install, at /guide/install. An index is served at its folder: the one at the top at /.

pages(import.meta.glob("../docs/**\/*.md", { eager: true, import: "default" }), [
  "index",
  { title: "Guide", pages: ["guide/install", "guide/theming"] },
]);

A name with no file, and a file that is not named, are both errors, so the list and the folder cannot drift apart.

This page as Markdown