Brix.Reader (Brix v0.1.1)

Copy Markdown View Source

Reads content files from the filesystem into Brix structs.

All functions take a content_dir path as the root of the content tree.

Summary

Functions

Formats a DateTime as a compact ISO string like "20241001T080000Z".

Parses a compact ISO timestamp directory name like "20241001T080000Z" into a DateTime. Returns nil if the format doesn't match.

Reads all author YAML files from authors/ and returns a sorted list of Brix.Author structs.

Reads all collection YAML files from collections/ and returns a sorted list.

Reads all layout YAML files from layouts/ and returns a sorted list of Brix.Layout structs.

Reads all media YAML files from media/ and returns a sorted list of Brix.Media structs.

Reads all page directories from pages/ and returns a sorted list of Brix.Page structs.

Reads all section template YAML files from templates/sections/ and returns a sorted list.

Reads all sections from a directory. Supports .yml, standalone .md, and mixed .field.md files (where a markdown file provides a single field value that is merged into its companion .yml section). Returns sections sorted by position.

Reads all shared section YAML files from shared_sections/ and returns a sorted list.

Reads site.yml from the content directory and returns a Brix.Site struct.

Reads all tag YAML files from tags/ and returns a sorted list of Brix.Tag structs.

Resolves shared section references in a list of sections. Takes a map of shared section name => %SharedSection{}.

Functions

format_compact_iso(dt)

@spec format_compact_iso(DateTime.t()) :: String.t()

Formats a DateTime as a compact ISO string like "20241001T080000Z".

parse_compact_iso(name)

@spec parse_compact_iso(String.t() | nil) :: DateTime.t() | nil

Parses a compact ISO timestamp directory name like "20241001T080000Z" into a DateTime. Returns nil if the format doesn't match.

read_authors(content_dir)

@spec read_authors(String.t()) :: [Brix.Author.t()]

Reads all author YAML files from authors/ and returns a sorted list of Brix.Author structs.

read_collections(content_dir)

@spec read_collections(String.t()) :: [Brix.Collection.t()]

Reads all collection YAML files from collections/ and returns a sorted list.

read_layouts(content_dir)

@spec read_layouts(String.t()) :: [Brix.Layout.t()]

Reads all layout YAML files from layouts/ and returns a sorted list of Brix.Layout structs.

read_media(content_dir)

@spec read_media(String.t()) :: [Brix.Media.t()]

Reads all media YAML files from media/ and returns a sorted list of Brix.Media structs.

read_pages(content_dir)

@spec read_pages(String.t()) :: [Brix.Page.t()]

Reads all page directories from pages/ and returns a sorted list of Brix.Page structs.

read_section_templates(content_dir)

@spec read_section_templates(String.t()) :: [Brix.SectionTemplate.t()]

Reads all section template YAML files from templates/sections/ and returns a sorted list.

read_sections(sections_dir)

@spec read_sections(String.t()) :: [Brix.Section.t()]

Reads all sections from a directory. Supports .yml, standalone .md, and mixed .field.md files (where a markdown file provides a single field value that is merged into its companion .yml section). Returns sections sorted by position.

read_shared_sections(content_dir)

@spec read_shared_sections(String.t()) :: [Brix.SharedSection.t()]

Reads all shared section YAML files from shared_sections/ and returns a sorted list.

read_site(content_dir)

@spec read_site(String.t()) :: {:ok, Brix.Site.t()} | {:error, term()}

Reads site.yml from the content directory and returns a Brix.Site struct.

read_tags(content_dir)

@spec read_tags(String.t()) :: [Brix.Tag.t()]

Reads all tag YAML files from tags/ and returns a sorted list of Brix.Tag structs.

resolve_sections(sections, shared_map)

@spec resolve_sections([Brix.Section.t()], %{
  required(String.t()) => Brix.SharedSection.t()
}) :: [
  Brix.Section.t()
]

Resolves shared section references in a list of sections. Takes a map of shared section name => %SharedSection{}.