Skip to content

Instantly share code, notes, and snippets.

@mattstauffer
Created September 5, 2017 01:02
Show Gist options
  • Save mattstauffer/99f63961c263c9b5eab620df07566046 to your computer and use it in GitHub Desktop.
Save mattstauffer/99f63961c263c9b5eab620df07566046 to your computer and use it in GitHub Desktop.
My build script for creating a new Jigsaw post
#!/bin/bash
function slugify {
echo "$1" | iconv -t ascii//TRANSLIT | sed -E s/[^a-zA-Z0-9]+/-/g | sed -E s/^-+\|-+$//g | tr A-Z a-z
}
# -------------------------------
echo
echo Creating a new blog post.
echo
echo Gimme a title:
read title
slug=`slugify "$title"`
# -------------------------------
buildpath="$PWD/source/_posts/$slug.md"
echo
echo "Creating a file at $buildpath"
touch $buildpath
date=`date +%Y-%m-%d`
cat <<EOT >> $buildpath
---
extends: _layouts.blog
section: markdown
title: "$title"
date: $date
series:
tags: []
---
EOT
vim $buildpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment