summaryrefslogtreecommitdiff
path: root/publish-blog.sh
diff options
context:
space:
mode:
Diffstat (limited to 'publish-blog.sh')
-rwxr-xr-xpublish-blog.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/publish-blog.sh b/publish-blog.sh
index e36ee63..c5a483f 100755
--- a/publish-blog.sh
+++ b/publish-blog.sh
@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
set -ex
if [ $# -gt 2 ]; then
@@ -42,3 +43,23 @@ mkdir -p ${path}
sed -E -i "s/BLOG_DATE/${date}/" $out
+# Update index (if needed)
+
+index=mds/blog/blog-index.md
+
+## check if exists
+exists=0
+grep -q -c "$isodate - $title" $index || exists=$?
+
+# Doesn't exist
+if [ $exists -eq 1 ]; then
+ marker="<!--NEXT-->"
+ line="1. [${isodate} - ${title}](/blog/${isodate}/)"
+ sed -E -i "/$marker/a $line" $index
+ ./compile-md.sh page "Blog Index" $index www/blog/index.html
+else
+ echo "Already exists in index - not updating"
+fi
+
+echo "Done"
+