From f609ba180872439f5607eb25e7823312034e57bc Mon Sep 17 00:00:00 2001 From: thinkpadmaster Date: Fri, 14 Jul 2023 00:48:43 -0500 Subject: Rename to postDeploy and add file moving functionality --- md/md2html.sh | 17 ----------------- md/postDeploy.sh | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) delete mode 100755 md/md2html.sh create mode 100755 md/postDeploy.sh diff --git a/md/md2html.sh b/md/md2html.sh deleted file mode 100755 index d45f38d..0000000 --- a/md/md2html.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# converts md to .tmpl.html with pandoc - -readonly POSTS_DIR="../../html/posts" -readonly POST_TEMP="POST_TEMPLATE.tmpl.html" - -post=$(basename "$1" .md) -echo "converting $post to HTML" - -# pandoc for md to html -pandoc -f markdown-auto_identifiers -t html --template=$POST_TEMP --wrap=none -o "$POSTS_DIR/$post.tmpl.html" "$post".md - -# # adds in filename to path no longer needed -# sed -i "s/posts\//posts\/$post/" "$POSTS_DIR/$post.tmpl.html" - -# makes http & https links have target _blank and rel noopener noreferrer -perl -i -0pe 's/(<\W*a\W*[^>]*href=)(["'"'"']http[s]?:\/\/[^"'"'"'>]*["'"'"'])([^>]*>)/$1$2 target="_blank" rel="noopener noreferrer"$3/g' "$POSTS_DIR/$post.tmpl.html" \ No newline at end of file diff --git a/md/postDeploy.sh b/md/postDeploy.sh new file mode 100755 index 0000000..3fb1412 --- /dev/null +++ b/md/postDeploy.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# converts md to .tmpl.html with pandoc +# Usage: ./postDeploy.sh title_of_post.md type +# type can be 'blog' or 'projects' in my case + +readonly POSTS_DIR="../html/$2" +readonly POST_TEMP="POST_TEMPLATE.tmpl.html" + +post=$(basename "$1" .md) +echo "converting $post to HTML" +echo "Outputting at '$POSTS_DIR/$post.tmpl.html'" + +# pandoc for md to html +pandoc -f markdown-auto_identifiers -t html --template=$POST_TEMP --wrap=none -o "$POSTS_DIR/$post.tmpl.html" "$post".md + +# # adds in filename to path no longer needed +# sed -i "s/posts\//posts\/$post/" "$POSTS_DIR/$post.tmpl.html" + +# makes http & https links have target _blank and rel noopener noreferrer +perl -i -0pe 's/(<\W*a\W*[^>]*href=)(["'"'"']http[s]?:\/\/[^"'"'"'>]*["'"'"'])([^>]*>)/$1$2 target="_blank" rel="noopener noreferrer"$3/g' "$POSTS_DIR/$post.tmpl.html" + +echo "moving $1 to 'deployed' folder" +mkdir -p "deployed/$post" +mv $1 "deployed/$post/$1" \ No newline at end of file -- cgit v1.2.3