diff options
| author | Bill <bill@billserver.senders.io> | 2022-11-18 21:58:23 -0500 | 
|---|---|---|
| committer | Bill <bill@billserver.senders.io> | 2022-11-18 21:58:23 -0500 | 
| commit | 2d2d766e9af6a6de66140fb056be7c744dfabca0 (patch) | |
| tree | 43ec45330b7707afb04f39efbf2dcdfada67a204 /publish-blog.sh | |
| parent | 55c5fcb71a6a73ac0ec099bfacd7a1f259152bf2 (diff) | |
Generate blog index from md
Diffstat (limited to 'publish-blog.sh')
| -rwxr-xr-x | publish-blog.sh | 21 | 
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" + |