diff --git a/build.lua b/build.lua index 4299278..8a65de6 100644 --- a/build.lua +++ b/build.lua @@ -5,6 +5,7 @@ local scaffold = require 'scaffold' local shapeshift = require 'shapeshift' -- Project-specific stuff +local rss = require 'feed.rss' local paramparser = require 'paramparser' local params = paramparser(...) package.loaded.params = params @@ -34,6 +35,8 @@ for idx, post in ipairs(posts) do scaffold.deep(tree, post.path, body) end +scaffold.deep(tree, "feeds/all.rss.xml", rss(posts)) + if params.delete then restia.utils.delete(params.output) end diff --git a/config/description b/config/description new file mode 100644 index 0000000..0d842c5 --- /dev/null +++ b/config/description @@ -0,0 +1 @@ +This is my personal blog with a focus on IT and Programming content unless I have something else to say. diff --git a/config/title b/config/title new file mode 100644 index 0000000..ce19f99 --- /dev/null +++ b/config/title @@ -0,0 +1 @@ +Talia's Blog diff --git a/lib/feed/rss.lua b/lib/feed/rss.lua new file mode 100644 index 0000000..0f96e4f --- /dev/null +++ b/lib/feed/rss.lua @@ -0,0 +1,36 @@ +local skooma = require 'skooma' +local config = require 'config' + +local xml = skooma.env() + +local function map(sequence, fun) + local new = {} + for key, value in ipairs(sequence) do + new[key] = fun(value) + end + return new +end + +return function(posts) + return tostring(xml.rss{ + version="2.0"; + ["xmlns:atom"]="http://www.w3.org/2005/Atom"; + xml.channel { + xml.title(config.title); + xml.link "https://blog.but.gay/"; + xml.description(config.description); + xml.language "en-uk"; + xml.lastBuildDate(os.date()); + map(posts, function(post) + local link = "https://blog.but.gay"..post.head.uri + return xml.item { + xml.title(post.head.title); + xml.description(post.head.description); + xml.link(link); + xml.guid(link); + xml.pubDate(os.date("%d %b %Y", post.head.timestamp)); + } + end) + } + }) +end diff --git a/templates/main.html.skooma.yue b/templates/main.html.skooma.yue index 3f74dbc..79c2bc8 100644 --- a/templates/main.html.skooma.yue +++ b/templates/main.html.skooma.yue @@ -39,6 +39,7 @@ content, data = select 1, ... html lang: "english" * head + * link rel: 'alternate', type: 'application/rss+xml', title: 'RSS 2.0 feed', href: "/feeds/all.rss.xml" * meta name: "view-transition", content: "same-origin" * meta charset: "UTF-8" * meta name: "viewport", content: "width=device-width"