diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-04-21 22:35:06 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-04-21 22:35:06 +0300 |
commit | 743249bed60ee78cf891577b308bbb84a2a65340 (patch) | |
tree | da310300a65f3bc545902f8c822bd032a99d6bba | |
parent | 62f1dfce5eb0e47b37d0135997153556841414b6 (diff) | |
download | benzin-743249bed60ee78cf891577b308bbb84a2a65340.tar.gz |
feat: provide default values for variables
-rw-r--r-- | Makefile | 56 |
1 files changed, 31 insertions, 25 deletions
@@ -1,40 +1,46 @@ # BENZIN Makefile -WEBSITE_URL=https://example.com -WEBSITE_TITLE=Example Website - -CONVERT=pandoc --from=gfm+emoji --to=html --section-divs --shift-heading-level-by=1 -PAGE_TEMPLATE=templates/page.html -OPENRING_TEMPLATE=templates/openring.html -RSS_TEMPLATE=templates/rss.xml -RSS_ITEM_TEMPLATE=templates/rss_item.xml - -EMOJI_SIZE=20 -EMOJI_STYLE=margin-bottom: -4px; - -BLOG_PREVIEW_MARKER=Recent blog posts - -RSS=out/blog/index.xml - -OPENRING_FOOTER=tmp/openring.html -OPENRING_URLS=src/urls - +include config.mk + +# Directories +SRC ?= src +TEMPLATES ?= templates +OUT ?= out + +# User supplied variables +WEBSITE_URL ?= https://example.com +WEBSITE_TITLE ?= Example Website +CONVERT ?= pandoc --from=gfm+emoji --to=html --section-divs --shift-heading-level-by=1 +EMOJI_SIZE ?= 20 +EMOJI_STYLE ?= margin-bottom: -4px; +BLOG_PREVIEW_MARKER ?= Recent blog posts + +# File locations +PAGE_TEMPLATE ?= templates/page.html +OPENRING_TEMPLATE ?= templates/openring.html +RSS_TEMPLATE ?= templates/rss.xml +RSS_ITEM_TEMPLATE ?= templates/rss_item.xml +OPENRING_URLS ?= src/urls +RSS ?= out/blog/index.xml + +# Sources BLOG_SOURCES=$(wildcard src/blog/*.md) +EMOJI_SOURCES=$(wildcard src/public/emoji/*) +PUBLIC_SOURCES=$(shell find src/public -type f) SOURCES=$(shell find src -type f -name "*.md") +# Outputs TMP_HTML=$(patsubst src/%.md, tmp/%.content.html, $(SOURCES)) HTML=$(patsubst src/%.md, out/%.html, $(SOURCES)) - +OPENRING_FOOTER=$(patsubst templates/%, tmp/%, $(OPENRING_TEMPLATE)) BLOG_XML=$(patsubst src/%.md, tmp/%.xml, $(filter-out src/blog/index.md, $(BLOG_SOURCES))) - -PUBLIC_SOURCES=$(shell find src/public -type f) PUBLIC=$(patsubst src/%, out/%, $(PUBLIC_SOURCES)) -EMOJI_SOURCES=$(wildcard src/public/emoji/*) .PHONY: clean all serve .SECONDARY: $(TMP_HTML) $(BLOG_XML) + all: $(HTML) $(RSS) $(PUBLIC) out/%.html: tmp/%.content.html tmp/%.meta.title tmp/%.meta.description $(PAGE_TEMPLATE) $(OPENRING_FOOTER) @@ -55,7 +61,7 @@ out/index.html: tmp/index.content.html $(PAGE_TEMPLATE) sed "/<\/main>/e cat $<" $(PAGE_TEMPLATE) > $@ sed -i \ -e '/<head>/{' \ - -e 'a <title>$(WEBSITE_TITLE)<\/title>' \ + -e "a <title>$(WEBSITE_TITLE)<\/title>" \ -e '}' $@ tmp/index.content.html: src/index.md tmp/emoji.sed tmp/blog/preview.md @@ -85,7 +91,7 @@ $(RSS): $(BLOG_XML) $(RSS_TEMPLATE) sed "/<\/channel>/e cat $(BLOG_XML)" $(RSS_TEMPLATE) > $@ sed -i \ -e '/<channel>/{' \ - -e 'a <title>$(WEBSITE_TITLE)<\/title>' \ + -e "a <title>$(WEBSITE_TITLE)<\/title>" \ -e "a <link>$(WEBSITE_URL)<\/link>" \ -e "a <lastPubDate>$$(date --rfc-email)<\/lastPubDate>" \ -e '}' $@ |