Skip to content

OgImage

type OgImage =
    {
        Url: string
        Alt: string option
        Width: int option
        Height: int option
    }
AssemblyPartas.Nacara.Plugins.OgImage

The image a page is shared with: what a link preview shows.

Declared inside

FrontMatterImageWhat a page's front matter says about its image

Fields

Url: string

An absolute url, or a path in the output such as /images/card.png.

A path is made absolute with the site's origin, since a crawler reading the tag has no page to resolve it against.

Alt: string option

What the image shows, for a reader who cannot see it.

Width: int option

Width in pixels, so a crawler can lay the preview out before fetching it.

Height: int option

Height in pixels.

Functions and values

[<Literal>] DataKey: string = "og-image"

Where the resolved image is stored on a page, as an OgImage option.

None means the page has no image, having opted out or found no fallback.

absoluteUrl (site: SiteInfo) (url: string) : string

The absolute url a crawler is given for an image.

A path is taken from the root of the output, under the site's base url. Without an origin there is nothing to make it absolute with, so it stays root-relative.

altKeys (value: string list) (options: OgImageOptions) : OgImageOptions

The front matter keys the alt text of a plain path is read from.

Parameter
valueThe value to use.
optionsThe options so far.
apply (site: SiteInfo) (image: OgImage) (html: string) : string

A rendered page with its image described in the head.

A head that already names an og:image is left alone: the theme chose.

create () : IPlugin

Og-image tags, with the default options: front matter only, no fallback.

createWith (configure: OgImageOptions -> OgImageOptions) : IPlugin

Og-image tags, configured.

Parameter
configureGiven the defaults, the options to use.
defaultImage (value: OgImage) (options: OgImageOptions) : OgImageOptions

The image of every page nothing else gave one.

Parameter
valueThe value to use.
optionsThe options so far.
defaults: OgImageOptions
excludeCollections (value: string list) (options: OgImageOptions) : OgImageOptions

Collections whose pages get no image at all.

Parameter
valueThe value to use.
optionsThe options so far.
fallback (value: Page -> OgImage option) (options: OgImageOptions) : OgImageOptions

The image of a page whose front matter names none, asked before the default.

Parameter
valueThe value to use.
optionsThe options so far.
fromFrontMatter (options: OgImageOptions) (mapping: YamlMappingNode) : FrontMatterImage

Read a page's image out of its front matter.

Parameter
optionsWhich keys to read.
mappingThe page's front matter.
frontMatterKeys (value: string list) (options: OgImageOptions) : OgImageOptions

The front matter keys a page names its image under, first match wins.

Parameter
valueThe value to use.
optionsThe options so far.
image (url: string) : OgImage

An image with nothing but its url.

Parameter
urlAn absolute url, or a path in the output.
localPath (url: string) : string option

The output path a site-relative image is served from, when it is one.

register (site: Site) : Site

Add og-image tags to a site.

registerWith (configure: OgImageOptions -> OgImageOptions) (site: Site) : Site

Add og-image tags to a site, configured.

Parameter
configureGiven the defaults, the options to use.
siteThe site being described.
resolve (options: OgImageOptions) (frontMatter: FrontMatterImage) (page: Page) : OgImage option

The image a page ends up with, front matter first and then the fallbacks.

Parameter
optionsThe fallbacks.
frontMatterWhat the page's front matter said.
pageThe page, handed to Fallback.
tags (site: SiteInfo) (image: OgImage) (html: string) : string list

The head tags for an image, skipping any the head already has.

Parameter
siteFor the origin that makes a path absolute.
imageWhat to describe.
htmlThe rendered page, to see what its head already says.
withAlt (alt: string) (image: OgImage) : OgImage

The same image, with alt text.

withSize (width: int) (height: int) (image: OgImage) : OgImage

The same image, with its dimensions in pixels.