21 lines
No EOL
506 B
Bash
21 lines
No EOL
506 B
Bash
#!/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
|
|
) |