summaryrefslogtreecommitdiff
path: root/generate-atom.lua
blob: 075dbb570e44e30c9c0b493eff4eb647ad9fd972 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env lua
local datetime = require"huh.datetime"
local config = require"huh.config".load(arg[1])
local posts = require"huh.blog".posts(config)
local prefix = "https://ignore.pl/"
local count = 5
for _, page in pairs(posts) do
	if count <= 0 then
		break
	end
	local url = prefix .. page.filename
	print"<entry>"
	print(string.format("<title>%s</title>", page.title))
	print(string.format("<id>%s</id>", url))
	print(string.format([[<link href="%s"/>]], url))
	-- TODO: Unlike shell implementation, updated date here is sourced only from the file and never from git!
	print(string.format("<updated>%s</updated>", page.updated or page.published))
	print(string.format("<published>%s</published>", page.published))
	print"</entry>"
	count = count - 1
end