summaryrefslogtreecommitdiff
path: root/old/publish-blog.sh
diff options
context:
space:
mode:
authorSteph Enders <steph@senders.io>2024-02-29 09:31:15 -0500
committerSteph Enders <steph@senders.io>2024-02-29 09:31:15 -0500
commit2b39175011422a0d8f96d7f598f46e2a781dd28f (patch)
treedd896a1e35e2ec194bfce829afd61f553652464a /old/publish-blog.sh
parent350a5058cf383733a7e75f753abdcd1cb7aae2c5 (diff)
Initial rework commit: Build Script POC and CSS done
I've created the main CSS layout and a proof of concept for the build script: this will actually build any "done" _post/ file and generate it as a workable HTML file. However, no index file generate, rss, or gemini is implemented
Diffstat (limited to 'old/publish-blog.sh')
-rwxr-xr-xold/publish-blog.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/old/publish-blog.sh b/old/publish-blog.sh
new file mode 100755
index 0000000..33190b6
--- /dev/null
+++ b/old/publish-blog.sh
@@ -0,0 +1,66 @@
+#!/usr/bin/env bash
+set -ex
+
+if [ $# -gt 2 ]; then
+ echo "./publish-blog.sh [isodate] mds/blog/blog-file.md"
+ exit 1
+fi
+
+if [ $# -lt 1 ]; then
+ echo "./publish-blog.sh [isodate] mds/blog/blog-file.md"
+ exit 1
+fi
+
+# Setup Dates
+
+isodate=$(date -I)
+date=$(date +"%B %d, %Y")
+if [ $# -eq 2 ]; then
+ isodate=$1
+ date=$(date --date="${isodate}" +"%B %d, %Y")
+ in=$2
+else
+ in=$1
+fi
+
+# Get Page Title
+
+title=$(head -n1 $in | sed -E 's/^[#]{1,2}[[:space:]]*(.+)[[:space:]]*$/\1/g')
+
+# File info
+path=./www/blog/${isodate}
+out=${path}/index.html
+
+# Make path
+
+mkdir -p ${path}
+
+# Compile md
+
+./compile-md.sh blog "${title}" $in $out
+
+# Update date
+
+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
+ ./update-feed.sh ${isodate} "${title}" $out
+else
+ echo "Already exists in index - not updating"
+fi
+
+echo "Done"
+