Add RSS feed
This commit is contained in:
parent
f7cc8e37a1
commit
3e4e3d84d6
5 changed files with 42 additions and 0 deletions
|
@ -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
|
||||
|
|
1
config/description
Normal file
1
config/description
Normal file
|
@ -0,0 +1 @@
|
|||
This is my personal blog with a focus on IT and Programming content unless I have something else to say.
|
1
config/title
Normal file
1
config/title
Normal file
|
@ -0,0 +1 @@
|
|||
Talia's Blog
|
36
lib/feed/rss.lua
Normal file
36
lib/feed/rss.lua
Normal file
|
@ -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
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue