Add robots and sitemap

This commit is contained in:
Talia 2025-09-04 17:36:40 +02:00
parent f4fa4a5d50
commit 3e1dbcfd50
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E
2 changed files with 21 additions and 1 deletions

View file

@ -1,4 +1,5 @@
local fun = require 'fun'
local xml = require "skooma.xml"
local json = require 'cjson'
local restia = require 'restia'
local scaffold = require 'scaffold'
@ -71,8 +72,9 @@ do -- Copy blog images
end
local function transform(tab)
local tr = shapeshift.table(tab, "keep")
return function(data)
local success, result = shapeshift.table(tab, "keep")(data)
local success, result = tr(data)
return result
end
end
@ -90,6 +92,19 @@ output_tree["posts.json"] = json.encode(
:totable()
)
local root = "https://blog.but.gay"
-- Generate sitemap
output_tree["sitemap.xml"] = xml.urlset {
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9";
fun.iter(posts)
:map(function(post)
return xml.url {
xml.loc(root .. post.path);
xml.lastmod(post.head.date);
}
end):totable()
}:render()
output_tree["index.html"] = tostring(page("index", output_tree["posts.json"]))
if params.cname then

View file

@ -14,6 +14,10 @@ local cpath = table.concat({
";",
}, ";")
task.robots {
"curl https://www.ditig.com/robots.txt > static/robots.txt";
}
task.setup {
description = "Sets up directories and dependencies";
"mkdir -p lua_modules .luarocks";
@ -27,6 +31,7 @@ task.clean {
task.build {
description = "Builds the page";
depends = "robots";
'mkdir -p .luarocks lua_modules';
'luarocks install --only-deps *.rockspec';
'tup';