chore: add test script for new post scaffolding

main
CrimsonTome 2023-01-30 01:48:20 +00:00 committed by Rowan Clark
parent 8b8fbfe472
commit 3c9fa7fe0c
No known key found for this signature in database
GPG Key ID: F620D51904044094
1 changed files with 41 additions and 0 deletions

41
new-post.sh Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
# if [ "$1" != "-h" ] || [ "$1" != "--help" ]; then
title="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
description=$2
date=$(date -u +%Y-%m-%d)
stripped_spaces=${title// /-}
filename="$(echo "$stripped_spaces" | tr '[:upper:]' '[:lower:]')".md
touch drafts/$filename
tee -a drafts/$filename <<EOF
---
title: $title
description: $description
date: $date
tags:
- add-tags
layout: layouts/post.njk
---
EOF
exit 0
# fi
# display_help() {
# echo "Usage: $0 [OPTION]... [ARGUMENTS]..."
# echo "Create a new post"
# echo
# echo "Options:"
# echo " -h, --help Display this help message and exit."
# echo
# echo "Arguments:"
# echo " Title The title of the post, will also be formatted for the file name."
# echo " Description The description of the post."
# }
Check if the -h or --help option is given
# if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
# display_help
# exit 0
# fi