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)))
45 # usage: build_page [page_template] [item_template] [display_message]
49 cat $(TEMPLATE_DIR)/$(1) > "$@"
50 $(call loop_article,"$@",$(2))
51 envsubst < "$@" | sponge "$@"
55 $(BUILD_DIR)/rolling.html:
56 $(call build_page,rollingpage.template.html,rollingitem.template.html,building rolling file)
59 $(BUILD_DIR)/archive.html:
60 $(call build_page,archivepage.template.html,archiveitem.template.html,building archive file)
63 $(BUILD_DIR)/feed.xml:
64 $(call build_page,feed.template.xml,feeditem.template.xml,building feed file)
67 $(BUILD_DIR)/$(ARTICLE_PATH)/%.html: $(SRC_DIR)/%.md
70 $(call export_article,"$<")
71 cat $(TEMPLATE_DIR)/articlepage.template.html > "$@"
72 # module pipeline starts here
73 ./$(MODULE_DIR)/md "$<" | sed -i "/<!-- _MOUNT_ARTICLECONTENT -->/r /dev/stdin" "$@"
74 . ./$(MODULE_DIR)/md-header "$<"
75 . ./$(MODULE_DIR)/readingtime "$<"
76 # module pipeline ends here
77 envsubst < "$@" | sponge "$@"
81 rm $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(BUILD_DIR)/feed.xml $(BUILD_DIR)/$(ARTICLE_PATH)/*