summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2021-08-13 23:14:38 +0300
committereug-vs <eugene@eug-vs.xyz>2021-08-13 23:14:38 +0300
commit4fa5a63695f30813723530b9cf63d197a1696c7a (patch)
tree914ce0a4ead902e6166a5689176ad435568d72b5
parenta6eb667c6b54bb3f084b5dd65711e81e975ce6c4 (diff)
downloadeug-vs-xyz-4fa5a63695f30813723530b9cf63d197a1696c7a.tar.gz
feat: dynamically set page title
-rw-r--r--Makefile14
-rwxr-xr-xhead.html (renamed from icon.html)0
2 files changed, 9 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 4f61ae7..27ca3f4 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,10 @@ BROWSER=brave
MARKDOWN=gfm+emoji
STYLESHEET=/style.css
+HEAD=head.html
HEADER=header.html
-ICON=icon.html
-PAGETITLE="Eugene's Space"
-PANDOC_ARGS=-s --from=$(MARKDOWN) --to=html -c $(STYLESHEET) -B $(HEADER) -H $(ICON) -M pagetitle=$(PAGETITLE) --shift-heading-level-by=1 --highlight-style=gruvbox.theme
+TITLE=Eugene's Space
+PANDOC_ARGS=-s --from=$(MARKDOWN) --to=html -c $(STYLESHEET) -B $(HEADER) -H $(HEAD) --shift-heading-level-by=1 --highlight-style=gruvbox.theme
LINK_SEDSTRING=s/.md)/.html)/g;
EMOJI_SEDSTRING=$(shell ./compile_emoji_sedstring.sh)
@@ -22,11 +22,15 @@ all: $(HTML)
%.html: %.md
@echo $@
- @sed "$(LINK_SEDSTRING) $(EMOJI_SEDSTRING)" $< | pandoc $(PANDOC_ARGS) > $@
+ @PAGETITLE=$$(sed '/^#/q' $< | sed 's/:[a-z]*://; s/#* //'); \
+ sed "$(LINK_SEDSTRING) $(EMOJI_SEDSTRING)" $< \
+ | pandoc $(PANDOC_ARGS) -M pagetitle="$$PAGETITLE | $(TITLE)" > $@
index.html: index.md blog/preview.md
@echo $@
- @sed "/Recent blog posts/r blog/preview.md" $< | sed "$(LINK_SEDSTRING) $(EMOJI_SEDSTRING)" | pandoc $(PANDOC_ARGS) > $@
+ @sed "/Recent blog posts/r blog/preview.md" $< \
+ | sed "$(LINK_SEDSTRING) $(EMOJI_SEDSTRING)" \
+ | pandoc $(PANDOC_ARGS) -M pagetitle="$(TITLE)" > $@
blog/preview.md: blog/index.md
@echo $@
diff --git a/icon.html b/head.html
index 2bd6654..2bd6654 100755
--- a/icon.html
+++ b/head.html