blogatto/config/feed/atom
Configuration for generating Atom 1.0 feeds from blog articles.
Each AtomFeed defines a single Atom feed output. Multiple feeds can be
configured (e.g., one per language) by adding multiple AtomFeed values
to the main Config via config.atom_feed().
During the build, each blog post’s metadata is passed to the optional
filter and serialize functions to control which posts appear in the
feed and how they are represented as Atom entries.
The types in this module mirror the Atom 1.0 specification as exposed
by the webls library used to serialize the feed.
Example
import blogatto/config/feed/atom
import gleam/option.{None}
import gleam/time/timestamp
let feed =
atom.new(
id: "https://example.com/",
title: atom.PlainText("My Blog"),
updated: timestamp.system_time(),
)
|> atom.author(atom.Person(
name: "Jane Doe",
email: None,
uri: None,
))
|> atom.subtitle("My personal blog")
Types
Configuration for a single Atom 1.0 feed output.
Channel-level fields mirror the standard Atom <feed> element.
The filter and serialize functions control which posts appear in the
feed and how they are represented. When either is None, a default
behavior is used.
pub type AtomFeed(msg) {
AtomFeed(
filter: option.Option(fn(feed.FeedMetadata(msg)) -> Bool),
output: String,
serialize: option.Option(
fn(feed.FeedMetadata(msg)) -> AtomFeedItem,
),
id: String,
title: Text,
updated: timestamp.Timestamp,
authors: List(Person),
link: option.Option(Link),
categories: List(Category),
contributors: List(Person),
generator: option.Option(Generator),
icon: option.Option(String),
logo: option.Option(String),
rights: option.Option(Text),
subtitle: option.Option(String),
)
}
Constructors
-
AtomFeed( filter: option.Option(fn(feed.FeedMetadata(msg)) -> Bool), output: String, serialize: option.Option( fn(feed.FeedMetadata(msg)) -> AtomFeedItem, ), id: String, title: Text, updated: timestamp.Timestamp, authors: List(Person), link: option.Option(Link), categories: List(Category), contributors: List(Person), generator: option.Option(Generator), icon: option.Option(String), logo: option.Option(String), rights: option.Option(Text), subtitle: option.Option(String), )Arguments
- filter
-
Optional predicate to include or exclude posts from this feed.
- output
-
Output file path for the generated feed, relative to
output_dir(e.g.,"/atom.xml"). - serialize
-
Optional function to convert post metadata into a feed entry.
- id
-
The unique identifier of the feed, typically a URL or URN.
- title
-
Title of the feed.
- updated
-
Last time the feed was updated.
- authors
-
List of authors of the feed.
- link
-
Optional link associated with the feed (e.g., the homepage).
- categories
-
List of categories that classify the feed.
- contributors
-
List of contributors to the feed.
- generator
-
Optional generator program identifying the software that produced the feed.
- icon
-
Optional small icon URL representing the feed.
- logo
-
Optional larger logo URL representing the feed.
- rights
-
Optional rights information for the feed (e.g., a copyright notice).
- subtitle
-
Optional subtitle or tagline for the feed.
A serialized Atom feed entry produced by the serialize function.
Fields mirror the standard Atom <entry> element. Only id, title,
and updated are required; the remaining fields are optional.
pub type AtomFeedItem {
AtomFeedItem(
id: String,
title: Text,
updated: timestamp.Timestamp,
authors: List(Person),
content: option.Option(Text),
link: option.Option(Link),
summary: option.Option(Text),
categories: List(Category),
contributors: List(Person),
published: option.Option(timestamp.Timestamp),
rights: option.Option(Text),
source: option.Option(Source),
)
}
Constructors
-
AtomFeedItem( id: String, title: Text, updated: timestamp.Timestamp, authors: List(Person), content: option.Option(Text), link: option.Option(Link), summary: option.Option(Text), categories: List(Category), contributors: List(Person), published: option.Option(timestamp.Timestamp), rights: option.Option(Text), source: option.Option(Source), )Arguments
- id
-
The unique identifier of the entry, typically a URL or URN.
- title
-
Title of the entry.
- updated
-
Last time the entry was updated.
- authors
-
Authors of this entry.
- content
-
Optional body content of the entry.
- link
-
Optional link associated with the entry (e.g., the post URL).
- summary
-
Optional short summary or description of the entry.
- categories
-
Categories that classify this entry.
- contributors
-
Contributors to this entry.
- published
-
Optional original publication timestamp.
- rights
-
Optional rights information for the entry.
- source
-
Optional reference to the original feed this entry was syndicated from.
A category that classifies an Atom feed or entry.
pub type Category {
Category(
term: String,
scheme: option.Option(String),
label: option.Option(String),
)
}
Constructors
-
Category( term: String, scheme: option.Option(String), label: option.Option(String), )Arguments
- term
-
The category term (the actual tag value).
- scheme
-
Optional URI identifying the categorization scheme.
- label
-
Optional human-readable label for the category.
Identifies the software that generated the Atom feed.
pub type Generator {
Generator(
uri: option.Option(String),
version: option.Option(String),
)
}
Constructors
-
Generator( uri: option.Option(String), version: option.Option(String), )Arguments
- uri
-
Optional URI identifying the generator program.
- version
-
Optional version string of the generator.
A link associated with an Atom feed or entry.
pub type Link {
Link(
href: String,
rel: option.Option(String),
content_type: option.Option(String),
hreflang: option.Option(String),
title: option.Option(String),
length: option.Option(Int),
)
}
Constructors
-
Link( href: String, rel: option.Option(String), content_type: option.Option(String), hreflang: option.Option(String), title: option.Option(String), length: option.Option(Int), )Arguments
- href
-
The target URI of the link.
- rel
-
Optional relation type (e.g.,
"self","alternate"). - content_type
-
Optional MIME type of the linked resource.
- hreflang
-
Optional language of the linked resource (e.g.,
"en"). - title
-
Optional human-readable title of the link.
- length
-
Optional length in bytes of the linked resource.
A person referenced as an author or contributor of a feed or entry.
pub type Person {
Person(
name: String,
email: option.Option(String),
uri: option.Option(String),
)
}
Constructors
-
Person( name: String, email: option.Option(String), uri: option.Option(String), )Arguments
- name
-
The full name of the person.
-
Optional email address.
- uri
-
Optional URI associated with the person (e.g., a homepage).
A reference to the original feed from which an entry was syndicated.
pub type Source {
Source(id: String, title: String, updated: timestamp.Timestamp)
}
Constructors
-
Source(id: String, title: String, updated: timestamp.Timestamp)Arguments
- id
-
The unique identifier of the source feed.
- title
-
The title of the source feed.
- updated
-
The last update timestamp of the source feed.
An Atom text construct, used for fields like title, summary,
content, and rights.
pub type Text {
PlainText(value: String)
Html(value: String)
XHtml(value: String)
}
Constructors
-
PlainText(value: String)Plain text content. Special characters are escaped on serialization.
-
Html(value: String)HTML content. The string is treated as escaped HTML.
-
XHtml(value: String)XHTML content. The string must be a valid XHTML fragment.
Values
pub fn author(
config: AtomFeed(msg),
person: Person,
) -> AtomFeed(msg)
Add an author to the feed. Prepends to the existing list.
pub fn category(
config: AtomFeed(msg),
cat: Category,
) -> AtomFeed(msg)
Add a category that classifies the feed. Prepends to the existing list.
pub fn contributor(
config: AtomFeed(msg),
person: Person,
) -> AtomFeed(msg)
Add a contributor to the feed. Prepends to the existing list.
pub fn filter(
config: AtomFeed(msg),
f: fn(feed.FeedMetadata(msg)) -> Bool,
) -> AtomFeed(msg)
Set the predicate used to include or exclude posts from this feed.
pub fn generator(
config: AtomFeed(msg),
generator: Generator,
) -> AtomFeed(msg)
Set the generator program for the feed.
pub fn icon(config: AtomFeed(msg), url: String) -> AtomFeed(msg)
Set the URL of a small icon representing the feed.
pub fn link(config: AtomFeed(msg), link: Link) -> AtomFeed(msg)
Set the link associated with the feed.
pub fn logo(config: AtomFeed(msg), url: String) -> AtomFeed(msg)
Set the URL of a larger logo representing the feed.
pub fn new(
id id: String,
title title: Text,
updated updated: timestamp.Timestamp,
) -> AtomFeed(msg)
Create a new AtomFeed with the three required Atom 1.0 fields.
All optional fields receive sensible defaults (None or empty lists).
Use the setter functions to customize them via piping.
pub fn output(
config: AtomFeed(msg),
path: String,
) -> AtomFeed(msg)
Set the output file path for the generated feed, relative to output_dir.
pub fn rights(config: AtomFeed(msg), text: Text) -> AtomFeed(msg)
Set the rights information for the feed (e.g., a copyright notice).
pub fn serialize(
config: AtomFeed(msg),
f: fn(feed.FeedMetadata(msg)) -> AtomFeedItem,
) -> AtomFeed(msg)
Set the function used to convert post metadata into a feed entry.