From 2d2d766e9af6a6de66140fb056be7c744dfabca0 Mon Sep 17 00:00:00 2001 From: Bill Date: Fri, 18 Nov 2022 21:58:23 -0500 Subject: Generate blog index from md --- publish-blog.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'publish-blog.sh') 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="" + 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" + -- cgit v1.2.3-54-g00ecf