#!/bin/bash

set -euo pipefail

base_template="
+++
date = \"%s\"
title = \"%s\"
slug = \"%s\"
tags = []
categories = []
+++
"

function create_post() {
    local title filename postslug postdate
    title="${1}"
    postdate="$(date +"%Y-%m-%d")"
    postslug="$(echo ${title:?} | tr -dc '[:alnum:][:space:]\n\r' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')"
    filename="${postslug}.md"
    printf "${base_template}" "${postdate}" "${title}" "${postslug}" > content/posts/"${filename}"
}

create_post "${@}"


Add script to generate skeleton files for blog posts
Add script to generate skeleton files for blog posts

Signed-off-by: Harsh Shandilya <c6ff3190142d3f8560caed342b4d93721fe8dacf@gmail.com>
