diff --git a/scripts/new-post.sh b/scripts/new-post.sh new file mode 100644 index 0000000..ca771f4 --- /dev/null +++ b/scripts/new-post.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -eu + +REPOSITORY_BASE=$(git rev-parse --show-toplevel) # get the absolute base directory of this repository + +read -p "Enter the post slug: " POST_SLUG +read -p "Create directory? (y/N) " CREATE_DIR +echo + +( + cd $REPOSITORY_BASE + if [[ "$CREATE_DIR" == [Yy]* ]]; then + OUTPUT_PATH="site/blog/$POST_SLUG/content.md" + mkdir -vp $(dirname $OUTPUT_PATH) + else + OUTPUT_PATH="site/blog/$POST_SLUG.md" + fi + + cp -v site/blog/_template.md $OUTPUT_PATH +) \ No newline at end of file