Fix for title in template

This commit is contained in:
2022-05-14 18:17:46 +02:00
parent ceb6d4f0ff
commit 9af05d6ffa
2 changed files with 16 additions and 17 deletions

View File

@@ -1,5 +1,9 @@
SHELL := /bin/bash SHELL := /bin/bash
# CSS to be included as stylesheets and alternate stylesheets
CSS := assets/ghost.css
ALTCSS := assets/ghost-dark.css assets/ghost-caca.css
TARGETS := $(patsubst %.md,%.html,$(wildcard *.md)) TARGETS := $(patsubst %.md,%.html,$(wildcard *.md))
CSSINC := assets/css.inc CSSINC := assets/css.inc
@@ -7,20 +11,16 @@ CSSINC := assets/css.inc
# https://github.com/jgm/pandoc-templates/blob/master/default.html5 # https://github.com/jgm/pandoc-templates/blob/master/default.html5
TEMPLATE := assets/pandoc-template.html5 TEMPLATE := assets/pandoc-template.html5
# CSS to be included as stylesheets and alternate stylesheets define ADD_LINE
CSS := assets/ghost.css printf '<link rel="%s" href="%s" title="%s">\n' "$(2)" "$(1)" "$(notdir $(basename $(1)))" >> $(3);
ALTCSS := assets/ghost-dark.css assets/ghost-caca.css endef
OPTS := --standalone --include-in-header=$(CSSINC) --template=$(TEMPLATE) \ # provide a title to pandoc. We take the first line starting with '#',
--metadata=title:"$(call TIT,$<)" --from=gfm --to=html5
# To provide a title to pandoc. We take the first line starting with '#',
# and remove initial '#' and spaces # and remove initial '#' and spaces
TITLE = $(shell sed -n '0,/^#/ s/^[# ]*//p' $1) TITLE = $(shell sed -n '0,/^#/ s/^[# ]*//p' $1)
define ADD_LINE OPTS = --standalone --include-in-header=$(CSSINC) --template=$(TEMPLATE) \
printf '<link rel="%s" href="%s">\n' "$(2)" "$(1)" >> $(3); --from=gfm --to=html5
endef
.PHONY: all html clean $(CSSINC) .PHONY: all html clean $(CSSINC)
@@ -32,12 +32,12 @@ clean:
@echo cleaning $(TARGETS) $(CSSINC) @echo cleaning $(TARGETS) $(CSSINC)
@rm -f $(TARGETS) $(CSSINC) @rm -f $(TARGETS) $(CSSINC)
$(CSSINC): $(_CSS) $(_ALTCSS) $(CSSINC): $(CSS) $(ALTCSS)
@echo generating $@ @echo generating $@
@rm -f $@ rm -f $@
@$(foreach css,$(_CSS),$(call ADD_LINE,$(css),stylesheet,$@)) $(foreach css,$(CSS),$(call ADD_LINE,$(css),stylesheet,$@))
@$(foreach css,$(_ALTCSS),$(call ADD_LINE,$(css),alternate stylesheet,$@)) $(foreach css,$(ALTCSS),$(call ADD_LINE,$(css),alternate stylesheet,$@))
%.html: %.md $(_CSS) %.html: %.md $(CSSINC)
@echo generating $@ @echo generating $@
@pandoc $(PANDOCOPTS) -o $@ $< pandoc $(OPTS) --metadata=title:"$(call TITLE,$<)" -o $@ $<

View File

@@ -36,7 +36,6 @@ $include-before$
$endfor$ $endfor$
$if(title)$ $if(title)$
<header id="title-block-header"> <header id="title-block-header">
<h1 class="title">$title$</h1>
$if(subtitle)$ $if(subtitle)$
<p class="subtitle">$subtitle$</p> <p class="subtitle">$subtitle$</p>
$endif$ $endif$