A blog post parsed by NimblePublisher from a markdown file in priv/posts/.
The filename must follow the pattern YYYY-MM-DD-slug.md. The date and slug
are derived from the filename; all other fields come from the %{...}
frontmatter map and the markdown body.
Summary
Functions
Build a post struct from a filename and parsed NimblePublisher attributes.
Normalize a free-form status value into one of the two atoms
:published or :draft.
Parse an ISO 8601 datetime string or pass through an existing
DateTime. Returns {:ok, DateTime.t()} on success, :error
on unparseable input.
Like parse_datetime/1 but raises ArgumentError on invalid input.
Return a URL-safe slug for a tag name. Used to build category page URLs.
Types
@type status() :: :published | :draft
Functions
Build a post struct from a filename and parsed NimblePublisher attributes.
Arguments
filenameis the absolute path to the markdown file.attrsis a map of the frontmatter attributes extracted byNimblePublisher.bodyis the HTML body rendered from the markdown source.
Returns
- A
%StaticBlog.Post{}struct.
Normalize a free-form status value into one of the two atoms
:published or :draft.
Accepts atoms, binaries, and nil. Any value other than a recognized
draft marker is treated as :published.
@spec parse_datetime(String.t() | DateTime.t()) :: {:ok, DateTime.t()} | :error
Parse an ISO 8601 datetime string or pass through an existing
DateTime. Returns {:ok, DateTime.t()} on success, :error
on unparseable input.
@spec parse_datetime!(String.t() | DateTime.t()) :: DateTime.t()
Like parse_datetime/1 but raises ArgumentError on invalid input.
Return a URL-safe slug for a tag name. Used to build category page URLs.
Arguments
tagis the raw tag string as it appears in frontmatter.
Returns
- A lowercase, dash-separated slug suitable for a URL path segment.
Examples
iex> StaticBlog.Post.tag_slug("localize")
"localize"
iex> StaticBlog.Post.tag_slug("ex_cldr")
"ex-cldr"
iex> StaticBlog.Post.tag_slug("Release Notes!")
"release-notes"