update `Makefile`

master
urosm 2024-05-17 15:35:32 +02:00
parent 493fc63f31
commit 4fdb624ab3
1 changed files with 14 additions and 9 deletions

View File

@ -1,22 +1,27 @@
SHELL = /bin/sh SHELL = /bin/sh
.SUFFIXES: .SUFFIXES:
# All notes referenced with internal links, starting from `index.md`.
NOTES = $(shell pandoc lua pandoc/collect_notes.lua index.md) NOTES = $(shell pandoc lua pandoc/collect_notes.lua index.md)
TARGETS = $(patsubst %.md,public_html/%.html,$(NOTES)) # All pages referenced with internal links, starting from `index.md`.
GETDEPS = $(patsubst %.md,public_html/%.html.part,$(shell pandoc lua pandoc/collect_links.lua $(1))) PAGES := $(patsubst %.md,public_html/%.html,$(NOTES))
DEPSMETAFLAGS = $(patsubst %,-M linkparts=%,$(filter-out $<,$^)) # All parts referenced with internal links in `$(1)`, plus the sitemap.
PARTS = $(patsubst %.md,public_html/%.html.part,$(shell pandoc lua pandoc/collect_links.lua $(1))) public_html/sitemap.html.part
PANDOCFLAGS = --data-dir pandoc
.PHONY: all .PHONY: all
all: $(TARGETS) all: $(PAGES)
.SECONDEXPANSION: .SECONDEXPANSION:
public_html/%.html: %.md \ public_html/%.html: flags = $(patsubst %,-M parts=%,$(filter-out $<,$^))
$$(call GETDEPS,%.md) \ public_html/%.html: %.md $$(call PARTS,%.md)
public_html/sitemap.html.part @echo $^
pandoc --data-dir pandoc -d bavbavhaus.net.yaml -M slug=$* $(DEPSMETAFLAGS) -o $@ $< pandoc $(PANDOCFLAGS) -d bavbavhaus.net.yaml -M slug=$* $(flags) -o $@ $<
.SECONDARY:
public_html/%.html.part: %.md public_html/%.html.part: %.md
pandoc --data-dir pandoc -d bavbavhaus.net.part.yaml --id-prefix $* -M url=$*.html -M slug=$* -o $@ $< pandoc $(PANDOCFLAGS) -d bavbavhaus.net.part.yaml --id-prefix $* -M url=$*.html -M slug=$* -o $@ $<
public_html/sitemap.html.part: $(NOTES) public_html/sitemap.html.part: $(NOTES)
pandoc lua pandoc/sitemap.lua index.md $@ pandoc lua pandoc/sitemap.lua index.md $@