mirror of
https://github.com/msfjarvis/msfjarvis.dev.git
synced 2024-06-03 04:18:56 +05:30
generate_post_skeleton: Shellcheck cleanup
Also generify passing of title to not require quoting the entire thing. Signed-off-by: Harsh Shandilya <msfjarvis@gmail.com>
This commit is contained in:
parent
08466309e3
commit
a3a4ba7e57
|
@ -2,23 +2,18 @@
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
base_template="
|
|
||||||
+++
|
|
||||||
date = \"%s\"
|
|
||||||
title = \"%s\"
|
|
||||||
slug = \"%s\"
|
|
||||||
tags = []
|
|
||||||
categories = []
|
|
||||||
+++
|
|
||||||
"
|
|
||||||
|
|
||||||
function create_post() {
|
function create_post() {
|
||||||
local title filename postslug postdate
|
local title filename postslug postdate
|
||||||
title="${1}"
|
if [ $# -lt 1 ]; then
|
||||||
|
echo -e "\033[01;31mProviding a title is a must!\033[0m"
|
||||||
|
return
|
||||||
|
else
|
||||||
|
title="${@}"
|
||||||
|
fi
|
||||||
postdate="$(date +"%Y-%m-%d")"
|
postdate="$(date +"%Y-%m-%d")"
|
||||||
postslug="$(echo ${title:?} | tr -dc '[:alnum:][:space:]\n\r' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')"
|
postslug="$(echo "${title}" | tr -dc '[:alnum:][:space:]\n\r' | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')"
|
||||||
filename="${postslug}.md"
|
filename="${postslug}.md"
|
||||||
printf "${base_template}" "${postdate}" "${title}" "${postslug}" > content/posts/"${filename}"
|
printf "+++\ndate = \"%s\"\ntitle = \"%s\"\nslug = \"%s\"\ntags = []\ncategories = []\n+++\n" "${postdate}" "${title}" "${postslug}" > content/posts/"${filename}"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_post "${@}"
|
create_post "${@}"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user