summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2020-02-28 13:20:59 +0100
committerJonas Smedegaard <dr@jones.dk>2020-02-28 13:20:59 +0100
commit44c54cb4324b3809a09593bc4741f23ffd44b40a (patch)
treee28d174d992785a94980bfe5c24464fe3dd83a48
parentc6cb40c4be31918ac9fd1458daa76855a2d63449 (diff)
set page title from initial header line
-rw-r--r--Makefile5
1 files changed, 4 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 87a0d32..73a0b7a 100644
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@ hypertext = $(subst index/index,index,$(markdown:%.mdwn=%/index.html))
graph := $(wildcard *.dot */*.dot */*/*.dot)
vectorimage-graph := $(graph:%.dot=%.svg)
+sitetitle := $(shell head --lines=1 index.mdwn | grep --perl-regexp --only-matching '^\#\s*\K(\S+(\s\S+)*)+')
+
compass_plugins = h5bp
all: $(hypertext) $(vectorimage-graph) style.css
@@ -21,8 +23,9 @@ $(vectorimage-graph): %.svg: %.dot Makefile
dot -Tsvg -o$@ $<
%.html %/index.html: %.mdwn $(hypertext-snippets) Makefile
+ $(eval title = $(shell head --lines=1 $< | grep --perl-regexp --only-matching '^\#\s*\K(\S+(\s\S+)*)+'))
$(if $(filter-out ./,$(dir $@)),mkdir -p $(dir $@))
- pandoc -s -c $(shell realpath --relative-to=$(dir $@) style.css) -B topbar.html -A footer.html -f markdown -t html -o $@ $<
+ pandoc -s $(if $(title),--metadata pagetitle='$(if $(filter-out $(sitetitle),$(title)),$(sitetitle) -- )$(title)') -c $(shell realpath --relative-to=$(dir $@) style.css) -B topbar.html -A footer.html -f markdown -t html -o $@ $<
%.css : %.scss Makefile
sassc --load-path /usr/share/sass/stylesheets $(compass_plugins:%=--load-path /usr/share/compass/frameworks/%/stylesheets) --style compressed $< $@