Add new-post.sh
This commit is contained in:
parent
88988a3d36
commit
8fd3aebdae
1 changed files with 21 additions and 0 deletions
21
scripts/new-post.sh
Normal file
21
scripts/new-post.sh
Normal file
|
@ -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
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue