blogatto/post

Blog post type representing a parsed markdown article.

A Post is produced by the build pipeline after parsing a markdown file with frontmatter metadata. The slug is derived from the post’s directory name, and the language is determined by the filename convention: index.md for the default language (None) or index-{lang}.md for a specific language.

Example

Given the following directory structure:

blog/
  my-first-post/
    index.md
    index-it.md

Two Post values are produced:

Types

A parsed blog post with rendered markdown contents.

Required frontmatter fields are title, date, and description. Any additional frontmatter keys are collected in extras.

pub type Post(msg) {
  Post(
    title: String,
    slug: String,
    url: String,
    date: timestamp.Timestamp,
    description: String,
    excerpt: String,
    language: option.Option(String),
    featured_image: option.Option(String),
    contents: List(element.Element(msg)),
    extras: dict.Dict(String, String),
  )
}

Constructors

  • Post(
      title: String,
      slug: String,
      url: String,
      date: timestamp.Timestamp,
      description: String,
      excerpt: String,
      language: option.Option(String),
      featured_image: option.Option(String),
      contents: List(element.Element(msg)),
      extras: dict.Dict(String, String),
    )

    Arguments

    title

    The post title, extracted from the title frontmatter field.

    slug

    URL-friendly identifier derived from the post’s directory name.

    url

    The absolute URL for this post (e.g., "https://example.com/blog/my-post/"). Constructed from the site URL, optional route prefix, optional language, and slug. Always ends with a trailing slash.

    date

    Publication date extracted from the date frontmatter field.

    description

    Short description extracted from the description frontmatter field.

    excerpt

    Post excerpt, generated by parsing the text of the rendered content.

    language

    The language of this post variant, or None for the default language. Derived from the filename: index-it.md produces Some("it").

    featured_image

    The featured image URL extracted from the featured_image frontmatter field, or None if not provided.

    contents

    The rendered markdown content as a list of Lustre elements.

    extras

    Additional frontmatter keys beyond the required fields.

Post metadata is used to provide the user the information to implement a custom route builder for the posts.

pub type PostMetadata {
  PostMetadata(
    title: String,
    slug: String,
    date: timestamp.Timestamp,
    description: String,
    language: option.Option(String),
    featured_image: option.Option(String),
    extras: dict.Dict(String, String),
  )
}

Constructors

  • PostMetadata(
      title: String,
      slug: String,
      date: timestamp.Timestamp,
      description: String,
      language: option.Option(String),
      featured_image: option.Option(String),
      extras: dict.Dict(String, String),
    )

    Arguments

    title

    The post title, extracted from the title frontmatter field.

    slug

    URL-friendly identifier derived from the post’s directory name.

    date

    Publication date extracted from the date frontmatter field.

    description

    Short description extracted from the description frontmatter field.

    language

    The language of this post variant, or None for the default language. Derived from the filename: index-it.md produces Some("it").

    featured_image

    The featured image URL extracted from the featured_image frontmatter field, or None if not provided.

    extras

    Additional frontmatter keys beyond the required fields.

Search Document