Sayfa.Builder (Sayfa v0.5.0)

Copy Markdown View Source

Orchestrates the full site build pipeline.

The builder runs through these stages:

  1. Resolve config — merge defaults, app env, and runtime options
  2. Discover — find all .md files in the content directory
  3. Parse — parse front matter and render Markdown for each file
  4. Classify — determine content type from directory structure, enrich with type metadata
  5. Filter — exclude drafts (unless drafts: true)
  6. Validate — log warnings for missing required fields (e.g., date on articles)
  7. Enrich — add reading time, table of contents, and prev/next navigation to content metadata
  8. Render — apply three-layer template pipeline for individual pages
  9. Archives — generate tag and category archive pages
  10. Indexes — generate paginated content type index pages
  11. Feeds — generate Atom feeds (main + per-type)
  12. Sitemap — generate XML sitemap

Examples

# Build with defaults
{:ok, result} = Sayfa.Builder.build()

# Build with custom paths
{:ok, result} = Sayfa.Builder.build(content_dir: "my_content", output_dir: "custom_dist")

# Clean output directory
:ok = Sayfa.Builder.clean(output_dir: "custom_dist")

Summary

Functions

Builds the site from content files to HTML output.

Removes the output directory.

Functions

build(opts \\ [])

@spec build(keyword()) :: {:ok, Sayfa.Builder.Result.t()} | {:error, term()}

Builds the site from content files to HTML output.

Options

All options from Sayfa.Config.resolve/1 are accepted, plus:

  • :content_dir — source content directory (default: "content")
  • :output_dir — output directory (default: "dist")
  • :drafts — include draft content (default: false)
  • :fingerprint — enable asset fingerprinting (default: true; set to false in dev)

Examples

{:ok, %Sayfa.Builder.Result{files_written: 2}} = Sayfa.Builder.build()

clean(opts \\ [])

@spec clean(keyword()) :: :ok

Removes the output directory.

Examples

:ok = Sayfa.Builder.clean(output_dir: "dist")