Rss

HTML & web

RSS 2.0 feed strings for static sites.

Build a Channel with items, then write the result of feed through Site.files (raw text beside Site.pages) or any other export path.

Rss.feed
    { title = "Docs"
    , link = "https://example.com/"
    , description = "Project documentation"
    , language = Just "en"
    , items =
        [ { title = "Quick start"
          , link = "https://example.com/docs/quick-start/"
          , description = "Install and run"
          , pubDate = Nothing
          }
        ]
    }

Types

Channel

type alias Channel =
{ title : String
, link : String
, description : String
, language : Maybe String
, items : List Item
}

Channel metadata plus items.

language becomes <language> when Just (for example "en").

Item

type alias Item =
{ title : String
, link : String
, description : String
, pubDate : Maybe String
}

One feed entry.

pubDate should be an RFC 822 date string when present (for example "Mon, 01 Jan 2024 00:00:00 GMT").

Values

escape

escape : String -> String

Escape text for XML element and attribute content.

Examples

Rss.escape "a < b & \"c\"" == "a < b & "c""

feed

feed : Channel -> String

Render a complete RSS 2.0 document (XML declaration included).

Examples

String.contains "<rss version=\"2.0\">" (Rss.feed channel)