Reads blog posts from disk at runtime.
When posts are created, updated, or deleted through the Micropub endpoint, the process is long-running and needs to see file-system changes immediately.
This module reads priv/posts/**/*.md from disk on every call, parses the
frontmatter map and markdown body, and returns a list of
StaticBlog.Post structs. There is no cache — each call re-reads.
Summary
Functions
Return all posts found under priv/posts/, sorted newest-first.
Load a single post by its slug.
Return the raw markdown body of the post with the given slug, without frontmatter.
Return the absolute path to the markdown file backing a given slug, or nil.
Return the absolute path to the priv/posts/ directory.
Functions
@spec all() :: [StaticBlog.Post.t()]
Return all posts found under priv/posts/, sorted newest-first.
Returns
- A list of
StaticBlog.Post.t/0structs sorted by:datedescending.
@spec by_slug(String.t()) :: StaticBlog.Post.t() | nil
Load a single post by its slug.
Arguments
slugis the URL slug portion of the post filename.
Returns
- The matching
StaticBlog.Post.t/0, ornilif no post has that slug.
Return the raw markdown body of the post with the given slug, without frontmatter.
Arguments
slugis the URL slug portion of the post filename.
Returns
- The markdown body as a string, or
nilif no post has that slug.
Return the absolute path to the markdown file backing a given slug, or nil.
Arguments
slugis the URL slug portion of the post filename.
Returns
- An absolute path string, or
nilif no file exists for that slug.
@spec posts_dir() :: Path.t()
Return the absolute path to the priv/posts/ directory.
Returns
- An absolute path string.