## templates
-templates are html snippets that you can customize. these templates are then pieced together to form the final html page. edit them to your liking. they can be found in the `templates/` directory.
+templates are html snippets that you can customize. these templates are then pieced together to form the final html page. edit them to your liking. they can be found in the `templates/` directory. Here's a brief description of each one:
+
+template | description
+------------------|-----------
+head | html before body
+foot | html after body
+archivebody | everything inside body of archive page
+archiveitem |
+rollingbody | everything inside body of rolling page
+rollingitem |
## modules
### global
`$SITEURL` - the SITEURL variable you set in the pinopress config
+
`$USERVAR1` - global variable you can use however you want
+
`$USERVAR2` - a second user defined global variable
### article only
`$ARTICLE_TITLE` - title of article, as set in article header
+
`$PUBLISHED_DATE` - the date/time the article was published, as set in the article header
## mounts
#!/usr/bin/make -sf
+## pinopress - the simple static blog generator
+## dependencies: sponge
+
+# user variables
SITEURL := https://blog.danieliu.xyz
USERVAR1 :=
USERVAR2 :=
SRC_DIR := articles
MODULE_DIR := modules
-ARTICLE_PATH := $(BUILD_DIR)/article
+ARTICLE_PATH := article
ARTICLE_LIST := $(basename $(shell ls $(SRC_DIR)))
# some helper functions
export USERVAR2="$(USERVAR2)"
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`
+ # vvv this is sorta ugly vvv
+ export ARTICLE_URL="$(SITEURL)/$(ARTICLE_PATH)/$(subst .md,.html,$(notdir "$(1)"))"
+endef
+
help:
echo 'pinopress help|build|clean'
-build: $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(ARTICLE_PATH)/$(addsuffix .html,$(ARTICLE_LIST))
+build: $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(addprefix $(BUILD_DIR)/$(ARTICLE_PATH)/,$(addsuffix .html,$(ARTICLE_LIST)))
.ONESHELL:
$(BUILD_DIR)/rolling.html:
echo 'building rolling file'
$(export_common)
cat $(TEMPLATE_DIR)/head.template.html $(TEMPLATE_DIR)/rollingbody.template.html $(TEMPLATE_DIR)/foot.template.html > "$@"
+ for article_file in `ls $(SRC_DIR)`; do
+ $(call export_article,"$(SRC_DIR)/$$article_file")
+ envsubst < $(TEMPLATE_DIR)/rollingitem.template.html | sed -i "/<!-- ROLLING_ITEMS -->/r /dev/stdin" "$@"
+ done
envsubst < "$@" | sponge "$@"
.ONESHELL:
envsubst < "$@" | sponge "$@"
.ONESHELL:
-$(ARTICLE_PATH)/%.html: articles/%.md
- echo 'parsing $^'
+$(BUILD_DIR)/$(ARTICLE_PATH)/%.html: $(SRC_DIR)/%.md
+ echo "parsing $<"
$(export_common)
- export ARTICLE_TITLE="$(shell ./$(MODULE_DIR)/md-header "$<" name)"
- export PUBLISHED_DATE="$(shell ./$(MODULE_DIR)/md-header "$<" published)"
+ $(call export_article,"$<")
cat $(TEMPLATE_DIR)/head.template.html > "$@"
# module pipeline starts here
./$(MODULE_DIR)/md "$^" >> "$@"
clean:
echo 'cleaning...'
- rm $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(ARTICLE_PATH)/*
+ rm $(BUILD_DIR)/rolling.html $(BUILD_DIR)/archive.html $(BUILD_DIR)/$(ARTICLE_PATH)/*