3 ## pinopress - the simple static blog generator
4 ## dependencies: sponge
7 SITEURL := https://blog.danieliu.xyz
13 .PHONY: help build clean
16 TEMPLATE_DIR := templates
21 ARTICLE_PATH := article
22 ARTICLE_LIST := $(basename $(shell ls $(SRC_DIR)))
24 # some helper functions
26 export SITEURL="$(SITEURL)"
27 export ARTICLE_PATH="$(ARTICLE_PATH)"
28 export USERGLOBAL1="$(USERGLOBAL1)"
29 export USERGLOBAL2="$(USERGLOBAL2)"
32 # usage: loop_article [dest] [template_filename]
34 for article_file in `ls $(SRC_DIR)`; do
35 . ./$(MODULE_DIR)/md-header "$(SRC_DIR)/$$article_file"
36 envsubst < $(TEMPLATE_DIR)/$(2) | sed -i "/<!-- $(shell echo $(addprefix mount_,$(basename $(basename $(2)))) | tr '[:lower:]' '[:upper:]') -->/r /dev/stdin" "$(1)"
41 echo 'pinopress help|build|clean'
43 build: $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(BUILD_DIR)/feed.xml $(addprefix $(BUILD_DIR)/$(ARTICLE_PATH)/,$(addsuffix .html,$(ARTICLE_LIST)))
46 $(BUILD_DIR)/rolling.html:
47 echo 'building rolling file'
49 cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/rollingbody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@"
50 $(call loop_article,"$@",rollingitem.template.html)
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 $(call loop_article,"$@",archiveitem.template.html)
59 envsubst < "$@" | sponge "$@"
62 $(BUILD_DIR)/feed.xml:
63 echo 'building feed file'
65 cat $(TEMPLATE_DIR)/feed.template.xml > "$@"
66 $(call loop_article,"$@",feeditem.template.xml)
67 envsubst < "$@" | sponge "$@"
70 $(BUILD_DIR)/$(ARTICLE_PATH)/%.html: $(SRC_DIR)/%.md
73 $(call export_article,"$<")
74 cat $(TEMPLATE_DIR)/head.template.html > "$@"
75 # module pipeline starts here
76 ./$(MODULE_DIR)/md "$<" >> "$@"
77 . ./$(MODULE_DIR)/md-header "$<"
78 . ./$(MODULE_DIR)/readingtime "$<"
79 # module pipeline ends here
80 cat $(TEMPLATE_DIR)/foot.template.html >> "$@"
81 envsubst < "$@" | sponge "$@"
85 rm $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(BUILD_DIR)/feed.xml $(BUILD_DIR)/$(ARTICLE_PATH)/*