diff options
Diffstat (limited to 'generate-index.lua')
-rwxr-xr-x | generate-index.lua | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/generate-index.lua b/generate-index.lua index b079434..1ab4db4 100755 --- a/generate-index.lua +++ b/generate-index.lua @@ -1,7 +1,8 @@ #!/usr/bin/env lua -local pretty = require"pl.pretty" +local config = require"pl.config" local dir = require"pl.dir" local gumbo = require"gumbo" +local tablex = require"pl.tablex" local function parse (stamp) @@ -23,16 +24,23 @@ local function describe (date) end +config = config.read(arg[1] or "huh.conf") or {} +config.excludes = tablex.makeset(config.excludes or {}) + + +local function matches (str) + if config.pattern then + return str:match(config.pattern) + end + return str +end + + local pages = dir.getfiles(".", "*.html") local takeaways = { ["published-on"] = "published", ["last-modified-on"] = "modified", } -local excludes = { - ["index.html"] = true, - ["graveyard_of_the_drawings.html"] = true, - ["plop.html"] = true, -} local posts = {} for _, filename in pairs(pages) do local document = gumbo.parseFile(filename) @@ -49,7 +57,7 @@ for _, filename in pairs(pages) do end end end - if properties.filename:match"^[^_]" and not excludes[properties.filename] then + if matches(properties.filename) and not config.excludes[properties.filename] then table.insert(posts, properties) end end |