gen-tags
a bash script that creates tag files
#!/usr/bin/env bash
usage() {
cat <&2
cat < "collections/_tag/$tag.md"
---
title: $tag
---
EOT
git add "collections/_tag/$tag.md"
}
die() {
local err="$1"
shift
test -n "$*" && echo "$*" >&2
exit $err
}
# the following will help create tag pages in the right place
test "$(git rev-parse --show-toplevel)" == "$PWD" || \
die 1 "please run ${0##*/} from the top level of the repository"
# parse the command-line options:
while getopts 'h' option; do
case "$option" in
h) usage; exit 0 ;;
?) usage; exit 0 ;;
esac
done
(( OPTIND-- ))
shift $OPTIND
if [ $# -gt 0 ]; then # process remaining args on the commandline
while [ $# -gt 0 ]; do
gen_tag_page "$1"
shift
done
else usage; fi