Skip to content

Theme

module Theme
AssemblyNacara.Theme.Default
Attributes[<RequireQualifiedAccess>]

The default theme: a documentation layout and the assets it needs.

Functions and values

create (options: ThemeOptions) : IPlugin

The theme's assets. Add it to the site alongside the layout you use.

css (value: string) (options: ThemeOptions) : ThemeOptions

CSS added to every page, after the theme's own.

For a rule or two - a token to override, one section to treat differently. Anything larger belongs in a file of its own, shipped as a static asset and linked with headExtra.

Parameter
valueThe rules, as they would be written in a stylesheet.
optionsThe options so far.
Theme.defaults
|> Theme.css """[data-section="reference"] { --nacara-sidebar-width: 20rem; }"""
defaults: ThemeOptions
docs (options: ThemeOptions) (name: string) : Collection<DocFrontMatter>

A documentation collection using the theme's front matter and layout.

Parameter
optionsThe theme's own configuration, which its layout is given.
nameWhat the collection is called, which is also the directory its content is read from.
Site.create "Nacara" |> Site.collection (Theme.docs options "docs")
editUrl (value: string) (options: ThemeOptions) : ThemeOptions

Base URL for the "edit this page" link.

Parameter
valueWhere an edit starts, such as https://github.com/owner/repo/edit/main/docs.
optionsThe options so far.
favIcon (value: string) (options: ThemeOptions) : ThemeOptions

The site's favicon.

Parameter
valueIts path, relative to the site root.
optionsThe options so far.
footer (value: ReactElement) (options: ThemeOptions) : ThemeOptions

What every page ends with.

Parameter
valueThe footer's markup.
optionsThe options so far.
headExtra (value: ReactElement list) (options: ThemeOptions) : ThemeOptions

Markup added at the end of <head> on every page.

Parameter
valueWhat to add - an analytics snippet, a font, a meta tag.
optionsThe options so far.
layout (options: ThemeOptions) (context: PageContext<DocFrontMatter>) : ReactElement

The layout for pages using the theme's own front matter.

Parameter
optionsThe theme's own configuration.
contextThe page and the site around it. Its front matter is read for the title, the description and which parts of the chrome to leave out.
menu (section: string) (items: MenuItem list) (options: ThemeOptions) : ThemeOptions

The menu for one section, replacing the one its pages would have produced.

Additive: call it once per section. A section you say nothing about gets a menu built from its pages, or the one a plugin offered.

Parameter
sectionThe first segment of the routes it covers, such as guide.
itemsWhat the menu holds.
optionsThe options so far.
Theme.defaults
|> Theme.menu "guide" [ Menu.page "guide/getting-started.md" ]
|> Theme.menu "plugins" [ Menu.page "plugins/overview.md" ]
menus (value: Map<string,MenuItem list>) (options: ThemeOptions) : ThemeOptions

Every menu at once, replacing any set before.

Parameter
valueThe menus, keyed by section.
optionsThe options so far.
navbar (value: NavbarItem list) (options: ThemeOptions) : ThemeOptions

The items on the left of the navbar, after the site's title.

Parameter
valueThe items, in the order they are shown.
optionsThe options so far.
navbarEnd (value: NavbarItem list) (options: ThemeOptions) : ThemeOptions

The items on the right of the navbar - search, a repository link, the theme toggle.

Parameter
valueThe items, in the order they are shown.
optionsThe options so far.
register (options: ThemeOptions) (site: Site) : Site

Add the theme's assets to a site.

Registers what the theme needs of the site. The layout is chosen per collection, with docs or layout.

Parameter
optionsThe theme's options: your navbar, your footer, your menus.
siteThe site you are describing.
shell<'FrontMatter> (options: ThemeOptions) (doc: DocPage) (context: PageContext<'FrontMatter>) : ReactElement

Render a full page with the theme's chrome.

Takes a DocPage rather than reading front matter itself, so a site with its own front-matter type uses the same layout by mapping onto that record.

Parameter
optionsThe theme's own configuration: navbar, menus, footer.
docWhat the theme needs to know about this page - its title, and which parts of the chrome it wants.
contextThe page and the site around it, whatever front-matter type the site declared.