Skip to content

Instantly share code, notes, and snippets.

@FredyRosero
Created May 12, 2022 16:27
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 FredyRosero/8c6edef6258ee184c6a97ceeb9f0b160 to your computer and use it in GitHub Desktop.
Save FredyRosero/8c6edef6258ee184c6a97ceeb9f0b160 to your computer and use it in GitHub Desktop.
Create a jekyll draft post (in the folder `_drafts`). Usage: ./createpost.sh [post's tittle]. No quotes are required.
#!/bin/bash
# https://jekyllrb.com/docs/front-matter/
Create() {
title="$@"
author='Fredy Rosero'
date=$(date +%F)
FILENAME="${date}-${title// /-}.md"
HEDAER="---\n"
HEDAER+="title: ${title}\n"
HEDAER+="author: ${author}\n"
HEDAER+="tags: [tag1, tag2]\n"
HEDAER+="date: ${date}'\n"
HEDAER+="layout: post\n"
HEDAER+="categories: [category]\n"
HEDAER+="excerpt_separator: <!--more-->\n"
HEDAER+="---\n"
BODY="![thumbnail]()\n\n"
BODY+="Abstract.\n"
BODY+=" <!--more-->\n\n"
BODY+="## Section 1.\n"
BODY+="Body of Section 1.\n"
echo -e $HEDAER$BODY > "./_drafts/${FILENAME}"
}
while getopts ":h" option; do
case $option in
?|h)
echo "useage: $(basename $0) [post's tittle]"
exit 1
;;
esac
done
if [ $OPTIND -eq 1 ]; then Create "$@"; fi
shift $((OPTIND-1))
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment