diff --git a/make.sh b/make.sh index cfd6136..f81cfac 100755 --- a/make.sh +++ b/make.sh @@ -4,7 +4,9 @@ set -e pd=/usr/bin/pandoc g=/bin/grep -postDir=/home/vilmibm/blog +postDir=/home/vilmibm/blog/posts + +# TODO generalize into one loop function makeHTML() { htmlDir=/home/vilmibm/public_html/blog @@ -25,7 +27,7 @@ function makeHTML() { pubdate=$($g "pubdate:" $p | sed 's/pubdate://') title=$($g "title:" $p | sed 's/title://') slug=$($g "slug:" $p | sed 's/slug://' | tr -d \[:blank:\]) - if [ -z "$pubdate" ] || [ -z "$title" ] + if [ -z "$pubdate" ] || [ -z "$title" ] || [ -z "$slug" ] then echo "warning: missing at least one of: pubdate, slug, title in ${p}" else @@ -40,12 +42,30 @@ function makeHTML() { echo "" >> $htmlIndex } -#function makeGopher() { -# # TODO -#} +function makeGopher() { + gopherPath=/home/vilmibm/public_gopher/blog + cd $postDir > /dev/null + + for p in $(ls *.md) + do + pubdate=$($g "pubdate:" $p | sed 's/pubdate://') + title=$($g "title:" $p | sed 's/title://') + slug=$($g "slug:" $p | sed 's/slug://' | tr -d \[:blank:\]) + if [ -z "$pubdate" ] || [ -z "$title" ] || [ -z "$slug" ] + then + echo "warning: missing at least one of: pubdate, slug, title in ${p}" + else + postPath="${gopherPath}/${slug}.md" + echo "# ${title}" > postPath + $g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" >> $postPath + fi + done +} + # #function makeGemini() { # # TODO #} makeHTML +makeGopher diff --git a/20220518.md b/posts/20220518.md similarity index 100% rename from 20220518.md rename to posts/20220518.md diff --git a/20220519.md b/posts/20220519.md similarity index 100% rename from 20220519.md rename to posts/20220519.md