summaryrefslogtreecommitdiff
path: root/generate-atom.lua
diff options
context:
space:
mode:
Diffstat (limited to 'generate-atom.lua')
-rwxr-xr-xgenerate-atom.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/generate-atom.lua b/generate-atom.lua
new file mode 100755
index 0000000..075dbb5
--- /dev/null
+++ b/generate-atom.lua
@@ -0,0 +1,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