aboutsummaryrefslogblamecommitdiff
path: root/v2/src/bin/sitemap
blob: 09f7eb14e1e6bac36fc14ee152d6f05511ef5354 (plain) (tree)







































































                                                                         
#!/bin/sh
set -eu

usage() {
	cat <<-'EOF'
		Usage:
		  sitemap
		  sitemap -h
	EOF
}

help() {
	cat <<-'EOF'


		Options:
		  -h, --help    show this message


		Process all generate "*.mapentry" files, combine them all
		together into the final "sitemap.xml" file.


		Examples:

		  Generate the final sitemap.xml:

		    $ sitemap > src/sitemap.xml
	EOF
}


for f in "$@"; do
	case "$f" in
		--)
			break
			;;
		--help)
			usage
			help
			exit
			;;
		*)
			;;
	esac
done

while getopts 'h' flag; do
	case "$flag" in
		h)
			usage
			help
			exit
			;;
		*)
			usage >&2
			exit 2
			;;
	esac
done
shift $((OPTIND - 1))



printf '<?xml version="1.0" encoding="UTF-8"?>\n'
printf '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'

find "$CONTENT_PREFIX"/ -type f -name '*.mapentry' |
	LANG=POSIX.UTF-8 sort |
	xargs cat

printf '</urlset>\n'