Browse Source

feat: gen-post script

restructure
Garrit Franke 3 years ago
parent
commit
0a32ce09d8
Signed by: garrit
GPG Key ID: 65586C4DDA55EA2C
  1. 8
      README.md
  2. 20
      contrib/gen-post.sh

8
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

20
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 <<EOF
---
title: $TITLE
date: "$DATE"
---
EOF
Loading…
Cancel
Save