From 30e831c9602ea5d4d0603f5ad03baff481771b4b Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 19 Aug 2020 00:10:08 +0200 Subject: Put extensions in Lua module instead of sneaking them in environment Note that neither .cache/config.lua nor .cache/site-tree.json get updated when EXTENSIONS changes. This could be hacked as follows: config = EXTENSIONS="$(EXTENSIONS)" ifneq "$(shell test -f $(config_token) && cat $(config_token))" \ "$(shell ./generate-config-token.py $(config))" .PHONY: $(lua_config) $(site_tree) $(config_token) endif Plus a recipe for config_token, and some dependencies on it. --- repo/www/convert-internal-links.lua | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'repo/www/convert-internal-links.lua') diff --git a/repo/www/convert-internal-links.lua b/repo/www/convert-internal-links.lua index e50352a..21054d1 100644 --- a/repo/www/convert-internal-links.lua +++ b/repo/www/convert-internal-links.lua @@ -1,10 +1,4 @@ -EXTENSIONS = {} - -string.gsub( - os.getenv("EXTENSIONS"), - "[^%s]+", - function (ext) EXTENSIONS[#EXTENSIONS+1] = ext end -) +local config = require 'config' function Link(link) if link.target:match("^[%w]+://") @@ -12,7 +6,7 @@ function Link(link) return link end - for _, ext in pairs(EXTENSIONS) + for _, ext in pairs(config.EXTENSIONS) do link.target = link.target:gsub("%."..ext.."$", ".html") end -- cgit v1.2.3