-
-
Save rtablada/37ed13e62f283c347f37 to your computer and use it in GitHub Desktop.
Create Jekyll posts with their YAML matter quickly from the command line.
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
jekyll-post () { | |
#!/bin/bash | |
echo "Title of post:" | |
read title | |
echo "Description of post:" | |
read description | |
echo "Tag post:" | |
read tags | |
dateStr=$(date +%Y'-'%m'-'%d'-') # Current date | |
blogFolder=~/boondoggles/thoughts/_posts # _posts folder of Jekyll blog | |
YAML=$'--- | |
layout: post | |
title: '$title' | |
description: '$description' | |
tags: ['$tags'] | |
---' # YAML matter at top of blog post | |
lowercase=$(echo "$title" | tr '[:upper:]' '[:lower:]') | |
formattedTitle=${lowercase// /-} | |
echo $formattedTitle | |
newFile=$dateStr$formattedTitle'.md' | |
echo "$YAML" > $blogFolder/$newFile # Create post in correct folder | |
vim $blogFolder/$newFile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment