diff --git a/README.md b/README.md index b8dfc55..75d0e80 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,12 @@ This is the repository for my personal blog. +## Generating posts + +Running the following command will generate a new blog post with the necessary boilerplate. +``` +./contrib/gen-post.sh My first post +# -> 2021-04-12-my-first-post.md +``` + https://blog.garrit.xyz diff --git a/contrib/gen-post.sh b/contrib/gen-post.sh new file mode 100755 index 0000000..854b50d --- /dev/null +++ b/contrib/gen-post.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# This script generates a new blog post. +# Example usage: +# ./contrib/gen-post.sh My first post + +DATE=$(date +"%Y-%m-%d") +TITLE="$@" +FILE_TITLE=$(printf "$TITLE" | tr " " "-" | tr "[A-Z]" "[a-z]") +FILE_NAME="$DATE-$FILE_TITLE.md" + +FULL_PATH="content/posts/$FILE_NAME" + +cat > $FULL_PATH <