summaryrefslogtreecommitdiffstats
path: root/_scripts/generate_index.lua
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-10-01 22:11:18 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2014-10-01 22:27:42 +0200
commitd857e13f7a8b3d5c938eaaeb005898b7a631233a (patch)
tree584adf2dd31d2151b8e9d1ee9957b4812f75260f /_scripts/generate_index.lua
parent95a011b0d729d4a31dd20d81b409417ac671a6ce (diff)
downloadalpine-mksite-d857e13f7a8b3d5c938eaaeb005898b7a631233a.tar.bz2
alpine-mksite-d857e13f7a8b3d5c938eaaeb005898b7a631233a.tar.xz
initial import of news posts
Diffstat (limited to '_scripts/generate_index.lua')
-rw-r--r--_scripts/generate_index.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/_scripts/generate_index.lua b/_scripts/generate_index.lua
new file mode 100644
index 0000000..06c183f
--- /dev/null
+++ b/_scripts/generate_index.lua
@@ -0,0 +1,35 @@
+#!/usr/bin/lua
+
+markdown = require('discount')
+yaml = require('yaml')
+
+function read_meta(file)
+ local f = assert(io.open(file))
+ local header, body = f:read("*a"):match("^(%-%-%-.-%-%-%-)(.*)$")
+ f:close()
+ local m = yaml.load(header)
+ m.pagename = file:gsub("%.md$", ""):gsub("^.*/", "")
+ m.md = file
+ m.html = m.pagename..".html"
+ return m
+end
+
+function print_md(meta)
+ io.write(("|%s|%s|\n"):format(meta.date, meta.title))
+end
+
+a = {}
+j=1
+for i=1, #arg do
+ local m = read_meta(arg[i])
+ if m.date then
+ a[j] = m
+ j = j + 1
+ end
+
+end
+table.sort(a, function(a,b)
+ return a.date < b.date
+end)
+io.write(yaml.dump(a))
+