summaryrefslogtreecommitdiff
path: root/Makefile
blob: 2352b122d65dc31a5c09a6d8afd558883a54455e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# BENZIN Makefile

BASE_URL=https://example.com

PANDOC_ARGS=--from=gfm+emoji --to=html --section-divs
HEADER=templates/header.html
OPENRING_TEMPLATE=templates/openring.html
RSS=out/blog/index.xml

OPENRING_FOOTER=tmp/openring.html
OPENRING_ARGS=-s https://eug-vs.xyz/blog/index.xml -s https://drewdevault.com/blog/index.xml

BLOG_SOURCES=$(wildcard src/blog/*.md)
SOURCES=$(wildcard src/*.md) $(BLOG_SOURCES)

TMP_HTML=$(patsubst src/%.md, tmp/%.content.html, $(SOURCES))
HTML=$(patsubst src/%.md, out/%.html, $(SOURCES))

BLOG_XML=$(patsubst src/%.md, tmp/%.xml, $(BLOG_SOURCES))

.PHONY: clean all
.SECONDARY: $(TMP_HTML)

all: $(HTML) $(RSS)

out/%.html: $(HEADER) tmp/%.content.html $(OPENRING_FOOTER)
	@mkdir -p $(@D)
	cat $^ > $@

tmp/%.content.html: src/%.md
	@mkdir -p $(@D)
	pandoc $(PANDOC_ARGS) $< > $@

$(RSS): $(BLOG_XML)
	@mkdir -p $(@D)
	@echo '<rss version="2.0"><channel>' > $@
	@echo "<title>TODO</title><link>$(BASE_URL)</link><description>TODO</description>" >> $@
	@echo "<lastBuildDate>$$(date --rfc-email)</lastBuildDate>" >> $@
	cat $^ >> $@
	@echo '</channel></rss>' >> $@

tmp/%.xml: tmp/%.content.html
	@echo '<item>' > $@
	@echo "  <link>$(BASE_URL)/$*.html</link>" >> $@
	@echo "  <pubDate>TODO</pubDate>" >> $@
	@echo "  <title>TODO</title>" >> $@
	@echo "  <description><![CDATA[" >> $@
	cat $< >> $@
	@echo "  ]]></description>" >> $@
	@echo '</item>' >> $@

$(OPENRING_FOOTER): $(OPENRING_TEMPLATE)
	@mkdir -p $(@D)
	openring $(OPENRING_ARGS) < $< > $@

clean:
	rm -rf tmp out