Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created September 2, 2013 16:30
Show Gist options
  • Save metaskills/6414713 to your computer and use it in GitHub Desktop.
Save metaskills/6414713 to your computer and use it in GitHub Desktop.
Jekyll tasks/post to help create a new post.
#!/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
@tpitale
Copy link

tpitale commented Sep 6, 2013

You could also use thor, if you have other tasks as well: https://github.com/tpitale/tpitale.github.com/blob/master/tasks/post.thor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment