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

brandIcon (value: BrandIcon) (options: ThemeOptions) : ThemeOptions

The icon before the site's title in the navbar.

Parameter
valueAn image file, by its path relative to the site root, or SVG markup.
optionsThe options so far.
Theme.defaults |> Theme.brandIcon (BrandIcon.Image "assets/logo.svg")
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, outside any layer, so it wins over 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; }"""
defaultStyles: Lazy<StyleLayer list>

The layers of the theme's stylesheet, first one lowest: tokens, base, navbar, layout, content, responsive.

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")
dropLayer (name: string) (options: ThemeOptions) : ThemeOptions

Remove a layer of the theme's stylesheet.

Parameter
nameThe layer, such as responsive. A name the theme does not have throws.
optionsThe options so far.
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.
layerAfter (anchor: string) (name: string) (css: string) (options: ThemeOptions) : ThemeOptions

Add a layer to the theme's stylesheet, after another one. It wins over the other layer.

Parameter
anchorThe layer to add it after. A name the theme does not have throws.
nameThe new layer, written as nacara.<name>.
cssThe rules of the layer.
optionsThe options so far.
Theme.defaults |> Theme.layerAfter "layout" "brand" (File.ReadAllText "css/brand.css")
layerBefore (anchor: string) (name: string) (css: string) (options: ThemeOptions) : ThemeOptions

Add a layer to the theme's stylesheet, before another one. The other layer wins over it.

Parameter
anchorThe layer to add it before. A name the theme does not have throws.
nameThe new layer, written as nacara.<name>.
cssThe rules of the layer.
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" ]
menuGroupLimit (value: int) (options: ThemeOptions) : ThemeOptions

Which groups are pruned, once a menu is over the limit.

Parameter
valueThe value to use. 0 prunes none of them.
optionsThe options so far.
menuLimit (value: int) (options: ThemeOptions) : ThemeOptions

How many pages a section's menu writes into a page before it prunes.

Parameter
valueThe value to use. 0 never prunes.
optionsThe options so far.
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.
parts (configure: ThemeParts -> ThemeParts) (options: ThemeOptions) : ThemeOptions

Replace how a part of the page is rendered, keeping the rest.

Parameter
configureWhat to change of the parts, starting from the theme's own.
optionsThe options so far.
Theme.defaults
|> Theme.parts (fun parts ->
{ parts with
Footer = fun context -> Html.div [ Parts.footer context; Html.p "Hosted by us" ] })
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.
replaceLayer (name: string) (css: string) (options: ThemeOptions) : ThemeOptions

Replace the rules of a layer of the theme's stylesheet. The layer keeps its place.

Parameter
nameThe layer, such as navbar. A name the theme does not have throws.
cssThe rules of the layer.
optionsThe options so far.
Theme.defaults |> Theme.replaceLayer "navbar" (File.ReadAllText "css/navbar.css")
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.
socialImage (value: string) (options: ThemeOptions) : ThemeOptions

The image a link to a page is shown with on social sites, for a page whose front matter names none.

Parameter
valueA path relative to the site root, or an absolute url.
optionsThe options so far.