- commit
- 6bf88fe90a31a8eccac44696e1d06ba272dc68c2
- parent
- 3a0d688c61bb4655dfc5cbe4359d78cf8df5a7aa
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-11-03 12:17
use pandoc to render templates
Diffstat
M | .gitignore | 1 | - |
M | Makefile | 8 | +++----- |
R | _content/index.html -> _content/index.md | 0 | |
M | _templates/base.html | 2 | +- |
M | _templates/feed.xml | 2 | +- |
D | build.py | 17 | ----------------- |
6 files changed, 5 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
@@ -3,4 +3,3 @@ build/**/*.md 3 3 build/**/*.css 4 4 build/feed.xml 5 5 _content/index.yml6 -1 _content/**/*.html
diff --git a/Makefile b/Makefile
@@ -2,7 +2,6 @@ 2 2 PAGES := $(shell find _content -name 'index.yml' | sed 's/^_content/build/;s/yml$$/html/') 3 3 PAGES_MD := $(shell find _content -name 'index.yml' | sed 's/^_content/build/;s/yml$$/md/') 4 4 IMG := $(shell find _content -regex '.*\.\(png\|gif\|jpg\)$$' | sed 's/^_content/build/')5 -1 MD_HTML := $(shell find _content -name '*.md' | sed 's/md$$/html/')6 5 7 6 .PHONY: all 8 7 all: build/index.html $(PAGES) $(PAGES_MD) build/feed.xml build/static/style.css $(IMG) @@ -32,12 +31,12 @@ build/%.jpg: _content/%.jpg 32 31 build/%.gif: _content/%.gif 33 32 ln $< $@ 34 3335 -1 _content/index.yml: _content/posts/*/index.yml posts.sh $(MD_HTML)-1 34 _content/index.yml: _content/posts/*/index.yml posts.sh 36 35 ./posts.sh > $@ 37 3638 -1 build/feed.xml: _content/index.yml _templates/feed.xml build.py-1 37 build/feed.xml: build/index.md _templates/feed.xml 39 38 @mkdir -p $$(dirname $@)40 -1 python build.py _templates/feed.xml /dev/null _content/feed.yml > $@-1 39 pandoc --template _templates/feed.xml -t html $< -o $@ 41 40 42 41 build/static/style.css: style/*.scss style/components/*.scss 43 42 npx sass --no-source-map style/style.scss $@ @@ -46,5 +45,4 @@ build/static/style.css: style/*.scss style/components/*.scss 46 45 clean: 47 46 rm -f $(PAGES) 48 47 rm -f $(PAGES_MD)49 -1 rm -f $(MD_HTML)50 48 rm -f _content/index.yml
diff --git a/_content/index.html b/_content/index.md
diff --git a/_templates/base.html b/_templates/base.html
@@ -43,7 +43,7 @@ 43 43 <ul class="blog"> 44 44 ${for(blog.posts)} 45 45 <li class="blog__post" data-tags="${for(it.tags)}${it}${sep} ${endfor}">46 -1 <a href="${it.url}">${blog.posts.title}</a>-1 46 <a href="${it.url}">${it.title}</a> 47 47 </li> 48 48 ${endfor} 49 49 </ul>
diff --git a/_templates/feed.xml b/_templates/feed.xml
@@ -8,7 +8,7 @@ 8 8 <link href="https://blog.ce9e.org/" rel="self" /> 9 9 10 10 ${if(blog)}11 -1 ${for(posts)}-1 11 ${for(blog.posts)} 12 12 <entry> 13 13 <title>${it.title}</title> 14 14 <link href="https://blog.ce9e.org${it.url}"/>
diff --git a/build.py b/build.py
@@ -1,17 +0,0 @@1 -1 import sys2 -13 -1 import yaml4 -1 import pystache5 -16 -17 -1 if __name__ == '__main__':8 -1 with open(sys.argv[1]) as fh:9 -1 template = fh.read()10 -1 with open(sys.argv[2]) as fh:11 -1 body = fh.read()12 -1 with open(sys.argv[3]) as fh:13 -1 data = yaml.safe_load(fh)14 -115 -1 data['body'] = body16 -1 renderer = pystache.Renderer(file_extension=False)17 -1 print(renderer.render(template, data))