Last active
December 1, 2017 15:06
-
-
Save AlexRiina/ab33ced029f9b6f065fd0501567e240b to your computer and use it in GitHub Desktop.
Publish Jekyll posts using simple git workflow
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
#!/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