Last active
December 25, 2022 16:22
-
-
Save lonelydev/736cc33b18a4892980a0f8072236f276 to your computer and use it in GitHub Desktop.
A little wrapper function to create a new hugo post with the title and timestamped
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
function hnp() { | |
post_name=$1 | |
if [[ -z $post_name ]] || [[ ${#post_name} -lt 5 ]]; then | |
echo "ERROR: Please provide a name for your post! Names must be at least 5 characters long." | |
echo "Usage: hnp this-is-my-post" | |
return 1 | |
fi | |
hugo new "post/"`date +"%Y-%m-%d"`"-$post_name.md" | |
} | |
export hnp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment