From 3e1dbcfd500f21dec7a49f76b50863caa41ccf49 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Thu, 4 Sep 2025 17:36:40 +0200 Subject: [PATCH] Add robots and sitemap --- build.lua | 17 ++++++++++++++++- tasks.lua | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/build.lua b/build.lua index 7e777fd..7442f74 100644 --- a/build.lua +++ b/build.lua @@ -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 diff --git a/tasks.lua b/tasks.lua index ce5b0cc..1c3a31c 100644 --- a/tasks.lua +++ b/tasks.lua @@ -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';