blogatto/config

Main configuration module for Blogatto.

The Config type holds all settings needed to build a static blog site. Use new(site_url) to create a configuration with the required base URL, then pipe it through the builder functions to set up feeds, routes, markdown, sitemap, robots, and static assets.

Example

import blogatto/config
import blogatto/config/markdown

let md =
  markdown.default()
  |> markdown.markdown_path("./blog")

let cfg =
  config.new("https://example.com")
  |> config.output_dir("./dist")
  |> config.static_dir("./static")
  |> config.markdown(md)

Types

Blogatto configuration. Contains everything needed to build a static blog site.

The generic msg type parameter threads the Lustre message type through the configuration, enabling type-safe component and view definitions.

pub type Config(msg) {
  Config(
    feeds: List(feed.FeedConfig(msg)),
    markdown_config: option.Option(markdown.MarkdownConfig(msg)),
    output_dir: String,
    robots: option.Option(robots.RobotsConfig),
    routes: dict.Dict(
      String,
      fn(List(post.Post(msg))) -> element.Element(msg),
    ),
    site_url: String,
    sitemap: option.Option(sitemap.SitemapConfig),
    static_dir: option.Option(String),
  )
}

Constructors

  • Config(
      feeds: List(feed.FeedConfig(msg)),
      markdown_config: option.Option(markdown.MarkdownConfig(msg)),
      output_dir: String,
      robots: option.Option(robots.RobotsConfig),
      routes: dict.Dict(
        String,
        fn(List(post.Post(msg))) -> element.Element(msg),
      ),
      site_url: String,
      sitemap: option.Option(sitemap.SitemapConfig),
      static_dir: option.Option(String),
    )

    Arguments

    feeds

    RSS feeds to generate, each with its own filter/serialize/output settings.

    markdown_config

    Markdown configuration for rendering blog articles. When None, no blog posts are built.

    output_dir

    Output directory for the built site. Default: "./dist".

    robots

    Robots.txt configuration. When None, no robots.txt is generated.

    routes

    Static routes mapping URL paths to view functions. Each view function receives the full list of blog posts, enabling pages that display recent posts, featured posts, or other post-based content.

    site_url

    The base URL of the site (e.g., "https://example.com"). Used to build absolute URLs for sitemaps, RSS feeds, and other outputs.

    sitemap

    Sitemap configuration. When None, no sitemap is generated.

    static_dir

    Path to a static assets directory to copy into the output root. When None, no static assets are copied.

Values

pub fn feed(
  config: Config(msg),
  feed: feed.FeedConfig(msg),
) -> Config(msg)

Add an RSS feed configuration to the build.

pub fn markdown(
  config: Config(msg),
  markdown_config: markdown.MarkdownConfig(msg),
) -> Config(msg)

Set the markdown configuration for blog post rendering.

pub fn new(site_url: String) -> Config(msg)

Create a new Config with the given base URL for the site.

The site_url is required because it is used to produce absolute URLs in sitemaps, RSS feeds, and robots.txt (e.g., "https://example.com").

Use the builder functions to further configure feeds, routes, markdown, and more.

pub fn output_dir(
  config: Config(msg),
  directory: String,
) -> Config(msg)

Set the output directory path for the built site.

pub fn robots(
  config: Config(msg),
  robots: robots.RobotsConfig,
) -> Config(msg)

Set the robots.txt configuration.

pub fn route(
  config: Config(msg),
  route: String,
  view: fn(List(post.Post(msg))) -> element.Element(msg),
) -> Config(msg)

Add a static route mapping a URL path to a view function.

The view function receives the full list of blog posts parsed during the build, allowing pages to display recent posts, featured posts, or other post-based content. The route path maps to {output_dir}/{route}/index.html.

pub fn sitemap(
  config: Config(msg),
  sitemap: sitemap.SitemapConfig,
) -> Config(msg)

Set the sitemap generation configuration.

pub fn static_dir(
  config: Config(msg),
  directory: String,
) -> Config(msg)

Set the path to a static assets directory.

During the build, the contents of this directory are copied into the root of output_dir.

Search Document