Creating Pelican Markdown Files

I have had a bash function to create new wiki entries for quite some time. I have been meaning to do the same for my blog but it was one more thing on the list. I finally got around to it.

First, ensure that the directory structure I want is created. Then create a markdown file pre-populated with the markdown structure Pelican needs for each post. I can just run the function on any Pelican blog and it will create a file for me.

I think that these new automation's I have added will help me post more often.

I need to figure out how to copy the file path to the clipboard still but other then that it seems to work well.

I also am curious if there is a way to execute this function directly from vscodium. UPDATE: vscodium has shell integration CTRL+`, this open's a shell in the CWD.

blog_entry ()
{
    if [[ -f $1/pelicanconf.py ]]; then
        BLOG_NAME=$1;
        BLOG_PATH="$(realpath $1)/content";
    else
        echo "Provide A Pelican Blog";
        return;
    fi;
    read -r YEAR MONTH DAY <<< $(date "+%Y %m %d");
    ENTRY_PATH="${BLOG_PATH}/${YEAR}/${MONTH}/${DAY}";
    if [ ! -d $ENTRY_PATH ]; then
        echo "$ENTRY_PATH Not Found: Creating";
        mkdir -p -p $ENTRY_PATH;
    fi;
    read -p "Enter title: " TITLE;
    read -p "Category: " CATEGORY;
    SLUG=$(tr [:upper:] [:lower:] <<< "$TITLE");
    SLUG=$(tr ' ' '-' <<< "$SLUG");
    OUTPUT_FILE="${ENTRY_PATH}/${SLUG}.md";
    if [ -e "$OUTPUT_FILE" ]; then
        printf "file already exists: exiting\n";
        return 100;
    fi;
    DATE=$(date "+%F %R");
    AUTHOR="Pat";
    MD_META="Title: %s\nSlug: %s\nDate: %s\nAuthor: %s\nCategory: %s\nTags:\nSummary:\nStatus: draft\n";
    printf "$MD_META" "$TITLE" "$SLUG" "$DATE" $AUTHOR "$CATEGORY" > "$OUTPUT_FILE";
    printf "Created markdown file:\n%s\n" "$OUTPUT_FILE"
}