package yocaml

  1. Overview
  2. Docs

A page is an archetype that naturally maps an HTML page, providing the necessary metadata to fill in the HTML-metadata (<meta ...>) and data to describe the various html tags (<title> and co). A page, which is often the basis of a compilation artifact, is also often associated with another archetype. For example, an Article is a page with additional fields.

Type

type t

A type describing a page with associated fields:

  • page_title an optional title
  • page_charset an optional page charset
  • description an optional page description
  • tags an optional list of tags
  • display_toc an optional flag to displaying the table of contents or not
  • toc an optional representation of the table of contents

The separation between fields prefixed with page_ and those without prefix allows you to distinguish between fields that describe page-specific behavior and those that don't describe generic behavior. For example, an article is also a page, but can be given a different page title.

Accessors

val title : t -> string option
val charset : t -> string option
val description : t -> string option
val tags : t -> string list
val with_toc : t -> string option -> t

Deal with Page as Metadata

A page can be parsed and injected.

val entity_name : string

Assigns a name to an entity (a set of metadata).

Describes a neutral element, as a fallback in the absence of metadata. The function can return an error if the request is mandatory.

validate raw_data Validates a data item represented by type Yocaml.Data.t and projects it into a value of type t.

In addition to the page_title, page_charset and page_description fields, normalization returns a meta field that contains a list of name; content records to easily derive a list of metadata based on the page fields.

It also exposes Boolean fields to determine whether a page has a title, description or charset with the parameters has_page_title, has_page_description, has_page_charset and has_page_tags.

val normalize : t -> (string * Data.t) list

Converts a value of type t into a value of type Yocaml.Data.t.

OCaml

Innovation. Community. Security.