Skip to content

Instantly share code, notes, and snippets.

@AlexRiina
Last active December 1, 2017 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexRiina/ab33ced029f9b6f065fd0501567e240b to your computer and use it in GitHub Desktop.
Save AlexRiina/ab33ced029f9b6f065fd0501567e240b to your computer and use it in GitHub Desktop.
Publish Jekyll posts using simple git workflow
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Move jekyll draft to post, timestamp it, and start to commit it
# Useage:
# $ ./publish.sh _draft/cool-article.markdown
# moves the draft to _posts/2017-12-01-cool-article.markdown
# inserts the published date into the "front matter"
# adds the changes and prompts you to commit them
original=$1
shortname=$(basename -s .markdown $original)
newfile="_posts/$(date -I)-${shortname}.markdown";
sed -i "2 i date: $(date '+%F %T %z')" $original
git mv "$original" "$newfile"
git add $newfile
git commit -e -m "publish $shortname"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment