struct

Plombir::Frontmatter::Document

Inherits Struct < Value < Object

A parsed document: raw YAML values plus the Markdown body.

Derived metadata (title, layout, date, tags, draft?) applies the roadmap ยง11.5 defaults โ€” see ADR-002. The source file and frontmatter block_lines are kept so value errors can report an exact file:line like every other Plombir diagnostic.

Constructors

new(data : Hash(String, YAML::Any), body : String, file : String = "<input>", block_lines : Array(String) = [] of String)
Source

Instance methods

body
Source
categories

Returns categories as a normalized list (categories: plus singular category: alias, merged deduped โ€” see ADR-008).

doc.categories # => ["guides", "news"]
Source
data
Source
date(default : Time | Nil = nil) : Time | Nil

Returns the page date: explicit date: (as YYYY-MM-DD or RFC3339, quoted or not), else default (the caller passes the file mtime โ€” see ADR-002), else nil.

doc.date(File.info(path).modification_time) # => 2026-09-13 00:00:00Z
Source
draft?

Returns whether the page is a draft (draft: true). Underscore paths are handled by Plombir::Content.discover.

doc.draft? # => false
Source
file
Source
layout

Returns the layout name, defaulting to "default".

doc.layout # => "post"
Source
line_of(key : String) : Int32

1-based file line of the key: entry, or 1 when unknown. Public for violation reporting (Schema points at the key).

Source
paginate_collection

Returns the paginated collection name (paginate_collection:), defaulting to "posts" (see ADR-007).

doc.paginate_collection # => "posts"
Source
paginate_path

Returns the paginated URL pattern (paginate_path: with :num), or nil when the <page_url>page/:num/ default applies.

doc.paginate_path # => "/blog/page:num/"
Source
paginate_per_page

Returns items per page for paginated listings (paginate: 5), or nil when the page is not paginated (see ADR-007).

doc.paginate_per_page # => 5
Source
string?(key : String) : String | Nil

Returns the string value for key, or nil when absent.

Source
tags

Returns tags as a normalized list: tags: plombir and the list form both work; items are stripped and empties dropped; a missing key means no tags.

doc.tags # => ["plombir", "hello"]
Source
title(filename_fallback : String) : String

Returns the page title: explicit title:, else the first # heading, else filename_fallback (usually the slug).

doc.title("hello-world") # => "Hello, world"
Source