Created
May 12, 2022 16:27
-
-
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.
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 | |
# 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