Allow customizing feed path

This commit is contained in:
Mikko Ahlroth 2024-04-12 23:36:15 +03:00
parent dce49028df
commit 925ee721fd
3 changed files with 17 additions and 2 deletions

View file

@ -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) {

View file

@ -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()

View file

@ -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),
)