diff --git a/src/gloss/paths.gleam b/src/gloss/paths.gleam index dc9548e..f07418c 100644 --- a/src/gloss/paths.gleam +++ b/src/gloss/paths.gleam @@ -7,6 +7,10 @@ import gloss/utils/date.{type Month} pub const default_index = "/index" +pub const default_feed_file = "/feed.xml" + +pub const default_feed = default_feed_file + pub type PathConfiguration { PathConfiguration( index: String, @@ -17,6 +21,8 @@ pub type PathConfiguration { month: fn(Int, Month) -> String, list_page: fn(String, Int) -> String, html: fn(String) -> String, + feed: String, + feed_file: String, ) } @@ -29,6 +35,8 @@ pub const defaults = PathConfiguration( month: default_month_archive, list_page: default_list_page, html: default_html, + feed: default_feed, + feed_file: default_feed_file, ) pub fn default_single_post(post: Post) { diff --git a/src/gloss/rendering/views/base.gleam b/src/gloss/rendering/views/base.gleam index 9594f5a..7af4b9d 100644 --- a/src/gloss/rendering/views/base.gleam +++ b/src/gloss/rendering/views/base.gleam @@ -9,7 +9,9 @@ import lustre/element/html.{ a, body, footer, h1, head, header, html, li, link, main, meta, nav, p, section, title, ul, } -import lustre/attribute.{attribute, href, id, name, rel, role, style, value} +import lustre/attribute.{ + attribute, href, id, name, rel, role, style, type_, value, +} import gloss/models/database.{type Database} import gloss/models/menu.{type MenuItem} import gloss/utils/ordered_tree @@ -60,6 +62,11 @@ fn view( link([href("/css/normalize.css"), rel("stylesheet")]), link([href("/css/magick.css"), rel("stylesheet")]), link([href("/css/custom.css"), rel("stylesheet")]), + link([ + href(config.paths.feed), + rel("alternate"), + type_("application/atom+xml"), + ]), case config.author.url { option.Some(url) -> link([rel("me"), value(url)]) _ -> element.none() diff --git a/src/gloss/writer.gleam b/src/gloss/writer.gleam index 14f03e6..aa46a60 100644 --- a/src/gloss/writer.gleam +++ b/src/gloss/writer.gleam @@ -71,7 +71,7 @@ pub fn write(db: RenderDatabase, path_conf: PathConfiguration) { let site = ssg.add_static_asset( site, - "/feed.xml", + path_conf.feed_file, element.to_string(xml.declaration()) <> element.to_string(db.feed), )