summaryrefslogtreecommitdiff
path: root/generate-atom.lua
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-09-03 21:35:27 +0200
committerAki <please@ignore.pl>2024-09-03 21:36:47 +0200
commit84d611c78ac65113ed8cc7838994669de270d4d0 (patch)
tree5832af26d8c4bfe0c48773e2dc69f3ecb1da52ef /generate-atom.lua
parented586b4fe54c9a3125cd7050f79a1b0d441644be (diff)
downloadhuh-master.zip
huh-master.tar.gz
huh-master.tar.bz2
Sketched generate-atom to generate RSS/Atom feeds along with indexHEADmaster
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