X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=pinopress;h=b47d785e49e20b4464cdf4e23d49f9ee343c5cb5;hb=6ec6ed4c15ad3c37fbe1076aa33d26e9c21050a9;hp=b457b131e7a33ac5be26daeca1a2fbbfdb969227;hpb=ae8408af2f6cac8cb64ff24aa1f2fe2c2255bf63;p=pinopress.git diff --git a/pinopress b/pinopress index b457b13..b47d785 100755 --- a/pinopress +++ b/pinopress @@ -8,6 +8,8 @@ SITEURL := https://blog.danieliu.xyz USERGLOBAL1 := USERGLOBAL2 := +include config.mk + .PHONY: help build clean # internal variables @@ -22,25 +24,15 @@ ARTICLE_LIST := $(basename $(shell ls $(SRC_DIR))) # some helper functions define export_common export SITEURL="$(SITEURL)" + export ARTICLE_PATH="$(ARTICLE_PATH)" export USERGLOBAL1="$(USERGLOBAL1)" export USERGLOBAL2="$(USERGLOBAL2)" endef -# usage: export_article [input md] -define export_article - export ARTICLE_TITLE=`./$(MODULE_DIR)/md-header "$(1)" name` - export PUBLISHED_DATE=`./$(MODULE_DIR)/md-header "$(1)" published` - export DESCRIPTION=`./$(MODULE_DIR)/md-header "$(1)" description` - export USERLOCAL1=`./$(MODULE_DIR)/md-header "$(1)" userlocal1` - export USERLOCAL2=`./$(MODULE_DIR)/md-header "$(1)" userlocal2` - # vvv this is sorta ugly vvv - export ARTICLE_URL="$(SITEURL)/$(ARTICLE_PATH)/$(subst .md,.html,$(notdir "$(1)"))" -endef - # usage: loop_article [dest] [template_filename] define loop_article for article_file in `ls $(SRC_DIR)`; do - $(call export_article,"$(SRC_DIR)/$$article_file") + . ./$(MODULE_DIR)/md-header "$(SRC_DIR)/$$article_file" envsubst < $(TEMPLATE_DIR)/$(2) | sed -i "//r /dev/stdin" "$(1)" done endef @@ -81,7 +73,9 @@ $(BUILD_DIR)/$(ARTICLE_PATH)/%.html: $(SRC_DIR)/%.md $(call export_article,"$<") cat $(TEMPLATE_DIR)/head.template.html > "$@" # module pipeline starts here - ./$(MODULE_DIR)/md "$^" >> "$@" + ./$(MODULE_DIR)/md "$<" >> "$@" + . ./$(MODULE_DIR)/md-header "$<" + . ./$(MODULE_DIR)/readingtime "$<" # module pipeline ends here cat $(TEMPLATE_DIR)/foot.template.html >> "$@" envsubst < "$@" | sponge "$@"