diff options
author | Bill <bill@billserver.senders.io> | 2022-11-06 11:42:43 -0500 |
---|---|---|
committer | Bill <bill@billserver.senders.io> | 2022-11-06 11:44:09 -0500 |
commit | 75fe6dd67e4affaa5d97d467fd2c30a163d90712 (patch) | |
tree | cf52f0e0b3cd8530a2bff9af2a9c18457267aea6 /publish-blog.sh | |
parent | 768f44a55bf757abe1bfc0829de301ade964354e (diff) |
Add script for blog publishing
Since a blog is written to the index.html its fairly easy to provide
just the date and the md file.
There still requires the line writing to the Blog Index.
Also suppress warning exit from tidy which outputs a 1 if warnings and a
2 if errors were present.
This method allows tidy.sh to be scriptable making warnings only return
a 0 as well (so I can still use set -e in the scripts)
Diffstat (limited to 'publish-blog.sh')
-rwxr-xr-x | publish-blog.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/publish-blog.sh b/publish-blog.sh new file mode 100755 index 0000000..e36ee63 --- /dev/null +++ b/publish-blog.sh @@ -0,0 +1,44 @@ +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/^##[[: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 + |