Add robots and sitemap
This commit is contained in:
parent
f4fa4a5d50
commit
3e1dbcfd50
2 changed files with 21 additions and 1 deletions
17
build.lua
17
build.lua
|
@ -1,4 +1,5 @@
|
||||||
local fun = require 'fun'
|
local fun = require 'fun'
|
||||||
|
local xml = require "skooma.xml"
|
||||||
local json = require 'cjson'
|
local json = require 'cjson'
|
||||||
local restia = require 'restia'
|
local restia = require 'restia'
|
||||||
local scaffold = require 'scaffold'
|
local scaffold = require 'scaffold'
|
||||||
|
@ -71,8 +72,9 @@ do -- Copy blog images
|
||||||
end
|
end
|
||||||
|
|
||||||
local function transform(tab)
|
local function transform(tab)
|
||||||
|
local tr = shapeshift.table(tab, "keep")
|
||||||
return function(data)
|
return function(data)
|
||||||
local success, result = shapeshift.table(tab, "keep")(data)
|
local success, result = tr(data)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -90,6 +92,19 @@ output_tree["posts.json"] = json.encode(
|
||||||
:totable()
|
: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"]))
|
output_tree["index.html"] = tostring(page("index", output_tree["posts.json"]))
|
||||||
|
|
||||||
if params.cname then
|
if params.cname then
|
||||||
|
|
|
@ -14,6 +14,10 @@ local cpath = table.concat({
|
||||||
";",
|
";",
|
||||||
}, ";")
|
}, ";")
|
||||||
|
|
||||||
|
task.robots {
|
||||||
|
"curl https://www.ditig.com/robots.txt > static/robots.txt";
|
||||||
|
}
|
||||||
|
|
||||||
task.setup {
|
task.setup {
|
||||||
description = "Sets up directories and dependencies";
|
description = "Sets up directories and dependencies";
|
||||||
"mkdir -p lua_modules .luarocks";
|
"mkdir -p lua_modules .luarocks";
|
||||||
|
@ -27,6 +31,7 @@ task.clean {
|
||||||
|
|
||||||
task.build {
|
task.build {
|
||||||
description = "Builds the page";
|
description = "Builds the page";
|
||||||
|
depends = "robots";
|
||||||
'mkdir -p .luarocks lua_modules';
|
'mkdir -p .luarocks lua_modules';
|
||||||
'luarocks install --only-deps *.rockspec';
|
'luarocks install --only-deps *.rockspec';
|
||||||
'tup';
|
'tup';
|
||||||
|
|
Loading…
Reference in a new issue