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, posts,
sitemap, robots, and static assets.
Example
import blogatto/config
import blogatto/config/post
let post_config =
post.default()
|> post.path("./blog")
let cfg =
config.new("https://example.com")
|> config.output_dir("./dist")
|> config.static_dir("./static")
|> config.post(post_config)
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(
atom_feeds: List(atom.AtomFeed(msg)),
output_dir: String,
post_config: option.Option(post.PostConfig(msg)),
robots: option.Option(robots.RobotsConfig),
routes: dict.Dict(
String,
fn(List(post.Post(msg))) -> element.Element(msg),
),
rss_feeds: List(rss.RssFeedConfig(msg)),
site_url: String,
sitemap: option.Option(sitemap.SitemapConfig),
static_dir: option.Option(String),
)
}
Constructors
-
Config( atom_feeds: List(atom.AtomFeed(msg)), output_dir: String, post_config: option.Option(post.PostConfig(msg)), robots: option.Option(robots.RobotsConfig), routes: dict.Dict( String, fn(List(post.Post(msg))) -> element.Element(msg), ), rss_feeds: List(rss.RssFeedConfig(msg)), site_url: String, sitemap: option.Option(sitemap.SitemapConfig), static_dir: option.Option(String), )Arguments
- atom_feeds
-
Atom feeds to generate, each with its own filter/serialize/output settings.
- output_dir
-
Output directory for the built site. Default:
"./dist". - post_config
-
Post configuration for rendering blog articles. When
None, no blog posts are built. - 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.
- rss_feeds
-
RSS feeds to generate, each with its own filter/serialize/output settings.
- 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 atom_feed(
config: Config(msg),
feed: atom.AtomFeed(msg),
) -> Config(msg)
Add an Atom feed configuration to the build.
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, posts, and more.
pub fn output_dir(
config: Config(msg),
directory: String,
) -> Config(msg)
Set the output directory path for the built site.
pub fn post(
config: Config(msg),
post_config: post.PostConfig(msg),
) -> Config(msg)
Set the post configuration for blog post rendering.
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 rss_feed(
config: Config(msg),
feed: rss.RssFeedConfig(msg),
) -> Config(msg)
Add an RSS feed configuration to the build.
pub fn sitemap(
config: Config(msg),
sitemap: sitemap.SitemapConfig,
) -> Config(msg)
Set the sitemap generation configuration.