#!/bin/sh # Metadata generator for static-site-scripts # It can also generate either the markdown pages or the html pages VERSION=$(git rev-parse --short HEAD) page_id="$(openssl rand -hex 3)" 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" EOF } show_help() { printf "\t${0}\n" printf "\tpart of static-site-scripts , version ${VERSION}\n" printf "\n" printf "\t-htm <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" } 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