3 ## pinopress - the simple static blog generator
4 ## dependencies: sponge
7 SITEURL := https://blog.danieliu.xyz
11 .PHONY: help build clean
14 TEMPLATE_DIR := templates
19 ARTICLE_PATH := article
20 ARTICLE_LIST := $(basename $(shell ls $(SRC_DIR)))
22 # some helper functions
24 export SITEURL="$(SITEURL)"
25 export USERVAR1="$(USERVAR1)"
26 export USERVAR2="$(USERVAR2)"
29 # usage: export_article [input md]
31 export ARTICLE_TITLE=`./$(MODULE_DIR)/md-header "$(1)" name`
32 export PUBLISHED_DATE=`./$(MODULE_DIR)/md-header "$(1)" published`
33 # vvv this is sorta ugly vvv
34 export ARTICLE_URL="$(SITEURL)/$(ARTICLE_PATH)/$(subst .md,.html,$(notdir "$(1)"))"
38 echo 'pinopress help|build|clean'
40 build: $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(addprefix $(BUILD_DIR)/$(ARTICLE_PATH)/,$(addsuffix .html,$(ARTICLE_LIST)))
43 $(BUILD_DIR)/rolling.html:
44 echo 'building rolling file'
46 cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/rollingbody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@"
47 for article_file in `ls $(SRC_DIR)`; do
48 $(call export_article,"$(SRC_DIR)/$$article_file")
49 envsubst < $(TEMPLATE_DIR)/rollingitem.template.html | sed -i "/<!-- ROLLING_ITEMS -->/r /dev/stdin" "$@"
51 envsubst < "$@" | sponge "$@"
54 $(BUILD_DIR)/archive.html:
55 echo 'building archive file'
57 cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/archivebody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@"
58 envsubst < "$@" | sponge "$@"
61 $(BUILD_DIR)/$(ARTICLE_PATH)/%.html: $(SRC_DIR)/%.md
64 $(call export_article,"$<")
65 cat $(TEMPLATE_DIR)/head.template.html > "$@"
66 # module pipeline starts here
67 ./$(MODULE_DIR)/md "$^" >> "$@"
68 # module pipeline ends here
69 cat $(TEMPLATE_DIR)/foot.template.html >> "$@"
70 envsubst < "$@" | sponge "$@"
74 rm $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(BUILD_DIR)/$(ARTICLE_PATH)/*