summaryrefslogtreecommitdiff
path: root/blogit
diff options
context:
space:
mode:
authorSylvain Gauthier <s94.gauthier@laposte.net>2021-01-17 12:44:49 +1100
committerSylvain Gauthier <s94.gauthier@laposte.net>2021-01-17 12:44:49 +1100
commit290ef63e425189d514d6e2461413e04ebd872521 (patch)
treefa2ece7b60899fa2052b977df74d2f60877dc264 /blogit
parentb630934434dd9f38a4652e73376fa9781da5a291 (diff)
expect .md extension for articles
Diffstat (limited to 'blogit')
-rwxr-xr-xblogit18
1 files changed, 9 insertions, 9 deletions
diff --git a/blogit b/blogit
index c8483cb..a0db362 100755
--- a/blogit
+++ b/blogit
@@ -18,7 +18,7 @@ BLOG_FEEDS ?= rss atom
.PHONY: help init build deploy clean
ARTICLES = $(shell git ls-tree HEAD --name-only -- articles/ 2>/dev/null)
-TAGFILES = $(patsubst articles/%,tags/%,$(ARTICLES))
+TAGFILES = $(patsubst articles/%.md,tags/%,$(ARTICLES))
help:
$(info blogit init|build|deploy|clean)
@@ -43,7 +43,7 @@ init:
printf '' > templates/article_footer.html
printf 'blog\n' > .git/info/exclude
-build: blog/index.html tagpages $(patsubst articles/%,blog/%.html,$(ARTICLES)) $(patsubst %,blog/%.xml,$(BLOG_FEEDS))
+build: blog/index.html tagpages $(patsubst articles/%.md,blog/%.html,$(ARTICLES)) $(patsubst %,blog/%.xml,$(BLOG_FEEDS))
deploy: build
rsync -rLtvz $(BLOG_RSYNC_OPTS) blog/ data/ $(BLOG_REMOTE)
@@ -56,7 +56,7 @@ config:
'$(shell printf "Blog remote (eg: host:/var/www/html): ">/dev/tty; head -n1)' \
> $@
-tags/%: articles/%
+tags/%: articles/%.md
mkdir -p tags
grep -i '^; *tags:' "$<" | cut -d: -f2- | sed 's/ */\n/g' | sed '/^$$/d' | sort -u > $@
@@ -83,9 +83,9 @@ blog/index.html: $(ARTICLES) $(TAGFILES) $(addprefix templates/,$(addsuffix .htm
git log --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \
done | sort -k2nr | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \
"$$first" || envsubst < templates/article_separator.html; \
- URL="`printf '%s' "\$$FILE" | sed 's,^articles/,,'`.html" \
+ URL="`printf '%s' "\$$FILE" | sed 's,^articles/\(.*\).md,\1,'`.html" \
DATE="$$DATE" \
- TITLE="`head -n1 "\$$FILE"`" \
+ TITLE="`head -n1 "\$$FILE" | sed -e 's/^# //g'`" \
envsubst < templates/article_entry.html; \
first=false; \
done >> $@; \
@@ -110,14 +110,14 @@ blog/@%.html: $(TAGFILES) $(addprefix templates/,$(addsuffix .html,header tag_in
envsubst < templates/tag_index_header.html >> $@; \
envsubst < templates/article_list_header.html >> $@; \
first=true; \
- for f in $(shell grep -FH '$*' $(TAGFILES) | sed 's,^tags/\([^:]*\):.*,articles/\1,'); do \
+ for f in $(shell grep -FH '$*' $(TAGFILES) | sed 's,^tags/\([^:]*\):.*,articles/\1.md,'); do \
printf '%s ' "$$f"; \
git log --diff-filter=A --date="format:%s $(BLOG_DATE_FORMAT_INDEX)" --pretty=format:'%ad%n' -- "$$f"; \
done | sort -k2nr | cut -d" " -f1,3- | while IFS=" " read -r FILE DATE; do \
"$$first" || envsubst < templates/article_separator.html; \
- URL="`printf '%s' "\$$FILE" | sed 's,^articles/,,'`.html" \
+ URL="`printf '%s' "\$$FILE" | sed 's,^articles/\(.*\).md,\1,'`.html" \
DATE="$$DATE" \
- TITLE="`head -n1 "\$$FILE"`" \
+ TITLE="`head -n1 "\$$FILE" | sed -e 's/^# //g'`" \
envsubst < templates/article_entry.html; \
first=false; \
done >> $@; \
@@ -126,7 +126,7 @@ blog/@%.html: $(TAGFILES) $(addprefix templates/,$(addsuffix .html,header tag_in
envsubst < templates/footer.html >> $@; \
-blog/%.html: articles/% $(addprefix templates/,$(addsuffix .html,header article_header article_footer footer))
+blog/%.html: articles/%.md $(addprefix templates/,$(addsuffix .html,header article_header article_footer footer))
mkdir -p blog
TITLE="$(shell head -n1 $<)"; \
export TITLE; \