hugo.soucy.cc

The personnal website source code of Hugo Soucy. Creates from an homebrewed static website generator (Ferron).
Log | Files | Refs

commit 3e6935974a8db300dde640b0373046b265f3f919
parent bd253e2e7505d9ee9d6784bbd6bedb656f715df7
Author: Hugo Soucy <hugo.soucy@savoirfairelinux.com>
Date:   Wed, 17 Jan 2018 17:05:37 -0500

Add a script to build tag pages.

Diffstat:
Atag.lua | 50++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+), 0 deletions(-)

diff --git a/tag.lua b/tag.lua @@ -0,0 +1,50 @@ +-- + +local inspect = require("inspect") +local json = require("dkjson") +local lfs = require("lfs") +local path = require("path") + +local function pullfilecontent(pathtofile) + local file = assert(io.open(pathtofile, "r")) + local content = file:read "*a" + + file:close() + + return content +end + +local function getpagetags() + dofile("site.config.lua") + + local tags = {} + + path.each( + lfs.currentdir() .. SITE.PATHS.CONTENT .. "/*.json", + function(j) + local metas = json.decode(pullfilecontent(j)) + + --print(inspect(metas)) + + if metas.keywords ~= nil then + for tag in metas.keywords:gmatch("([^,]+),%s*") do + tags[tag] = {} + + + --tags[#tag+1] = j + end + end + end, + { + delay = true; -- use snapshot of directory + recurse = true; -- include subdirs + reverse = false; -- subdirs at first + } + ) + + print(inspect(tags)) +end + +--return getpagetags + +getpagetags()