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:
Post(slug: "my-first-post", language: None, ...)Post(slug: "my-first-post", language: Some("it"), ...)
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
titlefrontmatter 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
datefrontmatter field. - description
-
Short description extracted from the
descriptionfrontmatter field. - excerpt
-
Post excerpt, generated by parsing the text of the rendered content.
- language
-
The language of this post variant, or
Nonefor the default language. Derived from the filename:index-it.mdproducesSome("it"). - featured_image
-
The featured image URL extracted from the
featured_imagefrontmatter field, orNoneif 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
titlefrontmatter field. - slug
-
URL-friendly identifier derived from the post’s directory name.
- date
-
Publication date extracted from the
datefrontmatter field. - description
-
Short description extracted from the
descriptionfrontmatter field. - language
-
The language of this post variant, or
Nonefor the default language. Derived from the filename:index-it.mdproducesSome("it"). - featured_image
-
The featured image URL extracted from the
featured_imagefrontmatter field, orNoneif not provided. - extras
-
Additional frontmatter keys beyond the required fields.