basic building
[pinopress.git] / pinopress
1 #!/usr/bin/make -sf
2
3 SITEURL := https://blog.danieliu.xyz
4
5 .PHONY: help build clean
6
7 # internal variables
8 TEMPLATE_DIR := templates
9 BUILD_DIR := build
10 SRC_DIR := articles
11 MODULE_DIR := modules
12
13 ARTICLE_PATH := $(BUILD_DIR)/article
14
15 ARTICLE_LIST := $(basename $(shell ls $(SRC_DIR)))
16
17 help:
18         echo 'pinopress help|build|clean'
19
20 build: $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(ARTICLE_PATH)/$(addsuffix .html,$(ARTICLE_LIST))
21         echo 'building...'
22
23 $(BUILD_DIR)/rolling.html:
24         echo 'building rolling file'
25         cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/rollingbody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@"
26
27 $(BUILD_DIR)/archive.html:
28         echo 'building archive file'
29         cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/archivebody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@"
30
31 $(ARTICLE_PATH)/%.html: articles/%.md
32         echo 'parsing $^'
33         cat $(TEMPLATE_DIR)/head.template.html > "$@"
34         # module pipeline starts here
35         ./$(MODULE_DIR)/md "$^" >> "$@"
36         # module pipeline ends here
37         cat $(TEMPLATE_DIR)/foot.template.html >> "$@"
38
39 clean:
40         echo 'cleaning...'
41         rm $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(ARTICLE_PATH)/*
42