-
-
Save jaandrle/a69323d8aee92b9083f28d5da28318d2 to your computer and use it in GitHub Desktop.
Jekyll tasks/post to help create a new post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ -z "$1" ]; then | |
echo "Usage: provide a title argument." | |
exit -1 | |
else | |
title="$@" | |
fi | |
d=$(date +"%Y-%m-%d") | |
slug=$(echo $title | tr '[:upper:]' '[:lower:]' | tr '[:space:]' '-') | |
slug="${slug:0:${#slug}-1}" | |
post="./_posts/$d-$slug.md" | |
body="" | |
read -d '' body <<EOF | |
--- | |
layout: post | |
title: $title | |
categories: | |
- | |
--- | |
EOF | |
echo "$body" > $post | |
subl . $post |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment