Theme
module Theme| Assembly | Nacara.Theme.Default |
| Attributes | [<RequireQualifiedAccess>] |
The default theme: a documentation layout and the assets it needs.
Functions and values
brandIcon (value: BrandIcon) (options: ThemeOptions) : ThemeOptions
brandIcon (value: BrandIcon) (options: ThemeOptions) : ThemeOptionsThe icon before the site's title in the navbar.
| Parameter | |
|---|---|
value | An image file, by its path relative to the site root, or SVG markup. |
options | The options so far. |
Theme.defaults |> Theme.brandIcon (BrandIcon.Image "assets/logo.svg")
create (options: ThemeOptions) : IPlugin
create (options: ThemeOptions) : IPluginThe theme's assets. Add it to the site alongside the layout you use.
css (value: string) (options: ThemeOptions) : ThemeOptions
css (value: string) (options: ThemeOptions) : ThemeOptionsCSS 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 | |
|---|---|
value | The rules, as they would be written in a stylesheet. |
options | The options so far. |
Theme.defaults
|> Theme.css """[data-section="reference"] { --nacara-sidebar-width: 20rem; }"""
defaultStyles: Lazy<StyleLayer list>
defaultStyles: Lazy<StyleLayer list>The layers of the theme's stylesheet, first one lowest: tokens, base, navbar, layout, content, responsive.
defaults: ThemeOptionsdocs (options: ThemeOptions) (name: string) : Collection<DocFrontMatter>
docs (options: ThemeOptions) (name: string) : Collection<DocFrontMatter>A documentation collection using the theme's front matter and layout.
| Parameter | |
|---|---|
options | The theme's own configuration, which its layout is given. |
name | What 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
dropLayer (name: string) (options: ThemeOptions) : ThemeOptionsRemove a layer of the theme's stylesheet.
| Parameter | |
|---|---|
name | The layer, such as responsive. A name the theme does not have throws. |
options | The options so far. |
editUrl (value: string) (options: ThemeOptions) : ThemeOptions
editUrl (value: string) (options: ThemeOptions) : ThemeOptionsBase URL for the "edit this page" link.
| Parameter | |
|---|---|
value | Where an edit starts, such as https://github.com/owner/repo/edit/main/docs. |
options | The options so far. |
favIcon (value: string) (options: ThemeOptions) : ThemeOptions
favIcon (value: string) (options: ThemeOptions) : ThemeOptionsThe site's favicon.
| Parameter | |
|---|---|
value | Its path, relative to the site root. |
options | The options so far. |
headExtra (value: ReactElement list) (options: ThemeOptions) : ThemeOptions
headExtra (value: ReactElement list) (options: ThemeOptions) : ThemeOptionsMarkup added at the end of <head> on every page.
| Parameter | |
|---|---|
value | What to add - an analytics snippet, a font, a meta tag. |
options | The options so far. |
layerAfter (anchor: string) (name: string) (css: string) (options: ThemeOptions) : ThemeOptions
layerAfter (anchor: string) (name: string) (css: string) (options: ThemeOptions) : ThemeOptionsAdd a layer to the theme's stylesheet, after another one. It wins over the other layer.
| Parameter | |
|---|---|
anchor | The layer to add it after. A name the theme does not have throws. |
name | The new layer, written as nacara.<name>. |
css | The rules of the layer. |
options | The options so far. |
Theme.defaults |> Theme.layerAfter "layout" "brand" (File.ReadAllText "css/brand.css")
layerBefore (anchor: string) (name: string) (css: string) (options: ThemeOptions) : ThemeOptions
layerBefore (anchor: string) (name: string) (css: string) (options: ThemeOptions) : ThemeOptionsAdd a layer to the theme's stylesheet, before another one. The other layer wins over it.
| Parameter | |
|---|---|
anchor | The layer to add it before. A name the theme does not have throws. |
name | The new layer, written as nacara.<name>. |
css | The rules of the layer. |
options | The options so far. |
layout (options: ThemeOptions) (context: PageContext<DocFrontMatter>) : ReactElement
layout (options: ThemeOptions) (context: PageContext<DocFrontMatter>) : ReactElementThe layout for pages using the theme's own front matter.
| Parameter | |
|---|---|
options | The theme's own configuration. |
context | The 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. |
parts (configure: ThemeParts -> ThemeParts) (options: ThemeOptions) : ThemeOptions
parts (configure: ThemeParts -> ThemeParts) (options: ThemeOptions) : ThemeOptionsReplace how a part of the page is rendered, keeping the rest.
| Parameter | |
|---|---|
configure | What to change of the parts, starting from the theme's own. |
options | The 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
register (options: ThemeOptions) (site: Site) : SiteAdd 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 | |
|---|---|
options | The theme's options: your navbar, your footer, your menus. |
site | The site you are describing. |
replaceLayer (name: string) (css: string) (options: ThemeOptions) : ThemeOptions
replaceLayer (name: string) (css: string) (options: ThemeOptions) : ThemeOptionsReplace the rules of a layer of the theme's stylesheet. The layer keeps its place.
| Parameter | |
|---|---|
name | The layer, such as navbar. A name the theme does not have throws. |
css | The rules of the layer. |
options | The options so far. |
Theme.defaults |> Theme.replaceLayer "navbar" (File.ReadAllText "css/navbar.css")
shell<'FrontMatter> (options: ThemeOptions) (doc: DocPage) (context: PageContext<'FrontMatter>) : ReactElement
shell<'FrontMatter> (options: ThemeOptions) (doc: DocPage) (context: PageContext<'FrontMatter>) : ReactElementRender 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 | |
|---|---|
options | The theme's own configuration: navbar, menus, footer. |
doc | What the theme needs to know about this page - its title, and which parts of the chrome it wants. |
context | The page and the site around it, whatever front-matter type the site declared. |
The image a link to a page is shown with on social sites, for a page whose front matter names none.
valueoptions