static-site-scripts/mkpage

52 lines
990 B
Plaintext
Raw Normal View History

2021-06-25 01:31:44 +00:00
#!/bin/sh
# Metadata generator for static-site-scripts
2021-08-17 12:27:47 +00:00
# It can also generate either the markdown pages or the html pages
2021-06-25 01:31:44 +00:00
2021-08-17 12:27:47 +00:00
VERSION=$(git rev-parse --short HEAD)
2021-06-25 01:31:44 +00:00
page_id="$(openssl rand -hex 3)"
2021-08-17 12:27:47 +00:00
gen_html() {
touch pages/${page_id}.html
}
gen_markdown() {
touch pages/${page_id}.md
}
gen_metadata() {
cat << EOF > pages/${page_id}.sh
#!/bin/sh
title="$2"
description="$3"
timecreated="$(date +%Y-%m-%d)"
timeupdated="$(date +%Y-%m-%d)"
author="$4"
id="${page_id}"
url="${page_id}.html"
2021-06-25 01:31:44 +00:00
EOF
2021-08-17 12:27:47 +00:00
}
show_help() {
printf "\t${0}\n"
printf "\tpart of static-site-scripts , version ${VERSION}\n"
printf "\n"
printf "\t-htm <title> <description> <author> \tGenerate metadata + html file\n"
printf "\t-md <title> <description> <author> \tGenerate metadata + markdown file\n"
printf "\t--help\tShow this help page\n"
}
2021-06-25 01:31:44 +00:00
2021-08-17 12:27:47 +00:00
case "$1" in
-htm)
gen_metadata "$2" "$3" "$4"
gen_html
;;
-md)
gen_metadata "$2" "$3" "$4"
gen_markdown
;;
--help)
show_help
;;
*)
show_help
;;
esac