blogatto/config/feed

Configuration for generating RSS feeds from blog articles.

Each FeedConfig defines a single RSS feed output. Multiple feeds can be configured (e.g., one per language) by adding multiple FeedConfig values to the main Config via config.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.

Example

import blogatto/config/feed

let rss =
  feed.new("My Blog", "https://example.com", "My personal blog")
  |> feed.language("en-us")
  |> feed.generator("Blogatto")

Types

Cloud configuration for RSS channel update notifications.

pub type Cloud {
  Cloud(
    domain: String,
    port: Int,
    path: String,
    register_procedure: String,
    protocol: String,
  )
}

Constructors

  • Cloud(
      domain: String,
      port: Int,
      path: String,
      register_procedure: String,
      protocol: String,
    )

    Arguments

    domain

    The domain of the cloud service.

    port

    The port for the cloud service.

    path

    The path for the cloud service.

    register_procedure

    The registration procedure (usually “http-post” or “xml-rpc”).

    protocol

    The protocol used for the cloud service.

An RSS feed item enclosure (e.g., a podcast audio file or image).

pub type Enclosure {
  Enclosure(url: String, length: Int, enclosure_type: String)
}

Constructors

  • Enclosure(url: String, length: Int, enclosure_type: String)

Configuration for a single RSS feed output.

Channel-level fields mirror the standard RSS 2.0 <channel> 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 FeedConfig(msg) {
  FeedConfig(
    excerpt_len: Int,
    filter: option.Option(fn(FeedMetadata(msg)) -> Bool),
    output: String,
    serialize: option.Option(fn(FeedMetadata(msg)) -> FeedItem),
    title: String,
    link: String,
    description: String,
    language: option.Option(String),
    copyright: option.Option(String),
    managing_editor: option.Option(String),
    web_master: option.Option(String),
    pub_date: option.Option(timestamp.Timestamp),
    last_build_date: option.Option(timestamp.Timestamp),
    categories: List(String),
    generator: option.Option(String),
    docs: option.Option(String),
    cloud: option.Option(Cloud),
    ttl: option.Option(Int),
    image: option.Option(Image),
    text_input: option.Option(TextInput),
    skip_hours: List(Int),
    skip_days: List(Weekday),
  )
}

Constructors

  • FeedConfig(
      excerpt_len: Int,
      filter: option.Option(fn(FeedMetadata(msg)) -> Bool),
      output: String,
      serialize: option.Option(fn(FeedMetadata(msg)) -> FeedItem),
      title: String,
      link: String,
      description: String,
      language: option.Option(String),
      copyright: option.Option(String),
      managing_editor: option.Option(String),
      web_master: option.Option(String),
      pub_date: option.Option(timestamp.Timestamp),
      last_build_date: option.Option(timestamp.Timestamp),
      categories: List(String),
      generator: option.Option(String),
      docs: option.Option(String),
      cloud: option.Option(Cloud),
      ttl: option.Option(Int),
      image: option.Option(Image),
      text_input: option.Option(TextInput),
      skip_hours: List(Int),
      skip_days: List(Weekday),
    )

    Arguments

    excerpt_len

    Maximum character length for article excerpts in the feed.

    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., "/rss.xml").

    serialize

    Optional function to convert post metadata into a feed item.

    title

    Title displayed in the RSS channel header.

    link

    The URL of the website corresponding to this channel.

    description

    A description of the channel.

    language

    The language the channel is written in (e.g., “en-us”).

    copyright

    Copyright notice for the channel content.

    managing_editor

    Email address for the managing editor.

    web_master

    Email address for the webmaster.

    pub_date

    The publication date of the channel content.

    last_build_date

    The last time the channel content changed.

    categories

    Category tags for the channel.

    generator

    A string indicating the program used to generate the channel.

    docs

    A URL that points to the documentation for the RSS format.

    cloud

    Cloud service configuration for channel update notifications.

    ttl

    Time to live: number of minutes the channel can be cached.

    image

    An image to display with the channel.

    text_input

    A text input area to display with the channel.

    skip_hours

    Hours (0-23) during which aggregators should skip updating.

    skip_days

    Days of the week during which aggregators should skip updating.

A serialized RSS feed item produced by the serialize function.

Fields mirror the standard RSS 2.0 <item> element. Only title and description are required; the remaining fields are optional.

pub type FeedItem {
  FeedItem(
    title: String,
    description: String,
    link: option.Option(String),
    author: option.Option(String),
    comments: option.Option(String),
    source: option.Option(String),
    pub_date: option.Option(timestamp.Timestamp),
    categories: List(String),
    enclosure: option.Option(Enclosure),
    guid: option.Option(String),
  )
}

Constructors

  • FeedItem(
      title: String,
      description: String,
      link: option.Option(String),
      author: option.Option(String),
      comments: option.Option(String),
      source: option.Option(String),
      pub_date: option.Option(timestamp.Timestamp),
      categories: List(String),
      enclosure: option.Option(Enclosure),
      guid: option.Option(String),
    )

    Arguments

    title

    Title of the feed entry.

    description

    Human-readable description or summary of the item.

    link

    The full URL for this entry.

    author

    Author email or name for this entry.

    comments

    URL pointing to comments for this item.

    source

    Source feed URL where this item originated.

    pub_date

    Publication timestamp for this feed entry.

    categories

    Category tags for this item.

    enclosure

    Media enclosure (e.g., podcast audio, image).

    guid

    Globally unique identifier for this feed item.

Metadata for a blog article passed to FeedConfig filter and serialize functions.

This provides enough context for the user to decide whether a post should appear in a feed and how it should be represented.

pub type FeedMetadata(msg) {
  FeedMetadata(
    path: String,
    excerpt: String,
    post: post.Post(msg),
    url: String,
  )
}

Constructors

  • FeedMetadata(
      path: String,
      excerpt: String,
      post: post.Post(msg),
      url: String,
    )

    Arguments

    path

    The article’s URL path (e.g., "/blog/my-post").

    excerpt

    Plain text excerpt extracted from the rendered article body, truncated to excerpt_len characters.

    post

    The parsed blog post with all frontmatter fields and rendered contents.

    url

    The absolute URL of the post.

An image associated with an RSS channel.

pub type Image {
  Image(
    url: String,
    title: String,
    link: String,
    description: option.Option(String),
    width: option.Option(Int),
    height: option.Option(Int),
  )
}

Constructors

  • Image(
      url: String,
      title: String,
      link: String,
      description: option.Option(String),
      width: option.Option(Int),
      height: option.Option(Int),
    )

    Arguments

    url

    The URL of the image.

    title

    The title of the image.

    link

    The link associated with the image.

    description

    An optional description of the image.

    width

    An optional width of the image in pixels.

    height

    An optional height of the image in pixels.

A text input field for an RSS channel.

pub type TextInput {
  TextInput(
    title: String,
    description: String,
    name: String,
    link: String,
  )
}

Constructors

  • TextInput(
      title: String,
      description: String,
      name: String,
      link: String,
    )

    Arguments

    title

    The title of the text input field.

    description

    A description of the text input field’s purpose.

    name

    The name attribute for the text input field.

    link

    The link associated with the text input field.

A day of the week for RSS channel skip days.

pub type Weekday {
  Monday
  Tuesday
  Wednesday
  Thursday
  Friday
  Saturday
  Sunday
}

Constructors

  • Monday
  • Tuesday
  • Wednesday
  • Thursday
  • Friday
  • Saturday
  • Sunday

Values

pub fn category(
  config: FeedConfig(msg),
  cat: String,
) -> FeedConfig(msg)

Add a category tag to the channel. Prepends to the existing list.

pub fn cloud(
  config: FeedConfig(msg),
  cloud: Cloud,
) -> FeedConfig(msg)

Set the cloud service configuration for channel update notifications.

pub fn copyright(
  config: FeedConfig(msg),
  text: String,
) -> FeedConfig(msg)

Set the copyright notice for the channel content.

pub fn docs(
  config: FeedConfig(msg),
  url: String,
) -> FeedConfig(msg)

Set a URL pointing to the documentation for the RSS format.

pub fn excerpt_len(
  config: FeedConfig(msg),
  len: Int,
) -> FeedConfig(msg)

Set the maximum character length for article excerpts in the feed.

pub fn filter(
  config: FeedConfig(msg),
  f: fn(FeedMetadata(msg)) -> Bool,
) -> FeedConfig(msg)

Set the predicate used to include or exclude posts from this feed.

pub fn generator(
  config: FeedConfig(msg),
  name: String,
) -> FeedConfig(msg)

Set the program name used to generate the channel.

pub fn image(
  config: FeedConfig(msg),
  image: Image,
) -> FeedConfig(msg)

Set the image to display with the channel.

pub fn language(
  config: FeedConfig(msg),
  lang: String,
) -> FeedConfig(msg)

Set the language code for the channel (e.g., "en-us").

pub fn last_build_date(
  config: FeedConfig(msg),
  ts: timestamp.Timestamp,
) -> FeedConfig(msg)

Set the last time the channel content changed.

pub fn managing_editor(
  config: FeedConfig(msg),
  email: String,
) -> FeedConfig(msg)

Set the email address for the managing editor.

pub fn new(
  title: String,
  link: String,
  description: String,
) -> FeedConfig(msg)

Create a new FeedConfig with the three required RSS 2.0 channel fields.

All optional fields receive sensible defaults (None, empty lists, or standard values). Use the setter functions to customize them via piping.

pub fn output(
  config: FeedConfig(msg),
  path: String,
) -> FeedConfig(msg)

Set the output file path for the generated feed, relative to output_dir.

pub fn pub_date(
  config: FeedConfig(msg),
  ts: timestamp.Timestamp,
) -> FeedConfig(msg)

Set the publication date of the channel content.

pub fn serialize(
  config: FeedConfig(msg),
  f: fn(FeedMetadata(msg)) -> FeedItem,
) -> FeedConfig(msg)

Set the function used to convert post metadata into a feed item.

pub fn skip_day(
  config: FeedConfig(msg),
  day: Weekday,
) -> FeedConfig(msg)

Add a day of the week during which aggregators should skip updating. Prepends to the existing list.

pub fn skip_hour(
  config: FeedConfig(msg),
  hour: Int,
) -> FeedConfig(msg)

Add an hour (0-23) during which aggregators should skip updating. Prepends to the existing list.

pub fn text_input(
  config: FeedConfig(msg),
  input: TextInput,
) -> FeedConfig(msg)

Set the text input area to display with the channel.

pub fn ttl(
  config: FeedConfig(msg),
  minutes: Int,
) -> FeedConfig(msg)

Set the time-to-live: number of minutes the channel can be cached.

pub fn web_master(
  config: FeedConfig(msg),
  email: String,
) -> FeedConfig(msg)

Set the email address for the webmaster.

Search Document