SRC := content
DST := $(HOME)/public_html/site
export DST
export SRC
sources := $(wildcard $(SRC)/*)
targets := $(sources:$(SRC)/%=$(DST)/%)
targets := $(targets:%.py=%)
targets := $(targets:%.md=%)
targets := $(filter-out $(DST)/.%.html,$(targets))
all: $(targets)
.PHONY: all firstpass clean upload
FORCE:
$(DST)/%: $(DST)/%.py FORCE
python3 $< > $@
$(DST)/%: $(DST)/%.md \
$(DST)/style.css \
$(DST)/.include-header.html \
$(DST)/.before-body.html \
$(DST)/.after-body.html
pandoc \
--include-in-header=$(DST)/.include-header.html \
--include-before-body=$(DST)/.before-body.html \
--include-after-body=$(DST)/.after-body.html \
--css="style.css" \
--smart \
--from=markdown+pipe_tables+header_attributes \
--to=html5 \
--standalone \
--base-header-level=2 \
$< > $@
# If using pandoc >=2, remove --smart and change --from to:
# --from=markdown+pipe_tables+header_attributes+smart \
$(DST)/%: $(SRC)/% | $(DST)
cp --preserve=timestamps $< $@
$(DST):
mkdir -p $(DST)
firstpass: $(filter-out $(DST)/index.html,$(filter $(DST)/%.html,$(targets)))
$(DST)/map.json: | firstpass
.INTERMEDIATE: $(DST)/index.html.md
$(DST)/index.html.md: $(DST)/map.json
watch:
while inotifywait -r content/ -e close_write; do $(MAKE) -rRj4; done
clean:
rm -f $(targets)