From 347d7c0da13079fefce6d8741a5604adb89eb97c Mon Sep 17 00:00:00 2001 From: Volpeon Date: Thu, 4 Aug 2022 10:26:57 +0200 Subject: Overhauled metadata handling --- Makefile | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 52a90f9..aaf589d 100644 --- a/Makefile +++ b/Makefile @@ -50,7 +50,7 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \ $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -maxdepth 1 -type f -name "*.md" ! -name "index.md") \ $(shell test -d $(patsubst .cache/meta%,content%,$(1)) && find $(patsubst .cache/meta%,content%,$(1)) -mindepth 2 -maxdepth 2 -type f -name "index.md")) -.cache/meta/%.json: content/%.md $$(call subpages,$$(call namespace,$$@,)) filters/*.lua scripts/pages_content.lua scripts/subpages.jq scripts/metadata.json | .cache/meta +.cache/meta/%.json: content/%.md $$(call subpages,$$(call namespace,$$@,)) filters/*.lua scripts/content.lua scripts/subpages.jq scripts/metadata.json | .cache/meta $(info [META] $< -> $@) mkdir -p $(@D) @@ -73,57 +73,70 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \ -f markdown-citations-implicit_figures \ -t html5 \ --wrap preserve \ - --lua-filter scripts/metadata.lua \ - --lua-filter scripts/pages_content.lua \ + --lua-filter scripts/content.lua \ $(GLOBAL_METADATA) \ --metadata-file "$@.meta" \ - --metadata build.mode="$(MODE)" \ - --metadata build.file_out="$(patsubst .cache/meta/%.json,/%.html,$@)" \ $(PANDOC_FILTERS) \ -o "$@.content" "$<" jq '. + { content: $$content }' --rawfile content "$@.content" "$@.meta" > "$@" rm "$@.meta" rm "$@.content" +.cache/meta.json: .cache/meta/index.json scripts/metadata.lua | .cache + $(info [META] $@) + + mkdir -p $(@D) + pandoc \ + -f markdown-citations-implicit_figures \ + -t html5 \ + --wrap preserve \ + --no-highlight \ + --lua-filter scripts/metadata.lua \ + $(GLOBAL_METADATA) \ + --metadata-file "$<" \ + --metadata build.mode="$(MODE)" \ + --template scripts/metadata.json \ + -o "$@" "$<" + .cache/assets.json: $(ASSET_FILES) | .cache + $(info [ASET] $@) + sha256sum $^ | sed -r 's/([0-9a-f]+) +out\/(.*)/{ "\2": "\/\2?\1" }/' | jq '{ assets: [inputs] | add | with_entries( .key |= gsub( "\\."; "_") ) }' > "$@" -out/%.html: content/%.md .cache/meta/%.json .cache/assets.json $(CONTENT_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata.lua | out +out/%.html: content/%.md .cache/meta.json .cache/assets.json $(CONTENT_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/page.lua | out $(info [MARK] $< -> $@) mkdir -p $(@D) - $(eval NAMESPACE = $(call namespace,$@,.cache/meta)) + $(eval NAMESPACE = $(call namespace,$@,out)) pandoc \ -f markdown-citations-implicit_figures \ -t html5 \ --wrap preserve \ --no-highlight \ --template templates/base.html \ - --lua-filter scripts/metadata.lua \ + --lua-filter scripts/page.lua \ $(GLOBAL_METADATA) \ --metadata-file .cache/assets.json \ - --metadata-file "$(filter .cache/meta/%.json,$^)" \ - --metadata build.mode="$(MODE)" \ + --metadata-file .cache/meta.json \ --metadata build.namespace="$(NAMESPACE)" \ --metadata build.file_out="$(patsubst out/%,/%,$@)" \ $(PANDOC_FILTERS) \ -o "$@" "$<" -out/%.xml: content/%.md .cache/meta/%.json $(FEED_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/metadata.lua | out +out/%.xml: content/%.md .cache/meta.json $(FEED_TEMPLATES_SRC) metadata/*.yaml filters/*.lua scripts/page.lua | out $(info [FEED] $< -> $@) mkdir -p $(@D) - $(eval NAMESPACE = $(call namespace,$@,.cache/meta)) + $(eval NAMESPACE = $(call namespace,$@,out)) pandoc \ -f markdown-citations-implicit_figures \ -t html5 \ --wrap preserve \ --no-highlight \ --template templates/feed.xml \ - --lua-filter scripts/metadata.lua \ + --lua-filter scripts/page.lua \ $(GLOBAL_METADATA) \ - --metadata-file "$(filter .cache/meta/%.json,$^)" \ - --metadata build.mode="$(MODE)" \ + --metadata-file .cache/meta.json \ --metadata build.namespace="$(NAMESPACE)" \ --metadata build.file_out="$(patsubst out/%,/%,$@)" \ $(PANDOC_FILTERS) \ -- cgit v1.2.3-70-g09d2