aboutsummaryrefslogtreecommitdiff
path: root/v2/src/bin/sitemap
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-04-10 19:20:55 -0300
committerEuAndreh <eu@euandre.org>2023-04-10 19:25:33 -0300
commit39eb7c48b9386a72fefc531ea58c5efef40505d2 (patch)
treeaa1cabde8226548c83eeaa06557a8a483a1c839a /v2/src/bin/sitemap
parentv2: src/bin/html: Remove empty lines from {pre,post}amble.html after processing (diff)
downloadeuandre.org-39eb7c48b9386a72fefc531ea58c5efef40505d2.tar.gz
euandre.org-39eb7c48b9386a72fefc531ea58c5efef40505d2.tar.xz
v2: Generate sitemap.xml
Diffstat (limited to '')
-rwxr-xr-xv2/src/bin/sitemap72
1 files changed, 72 insertions, 0 deletions
diff --git a/v2/src/bin/sitemap b/v2/src/bin/sitemap
new file mode 100755
index 0000000..09f7eb1
--- /dev/null
+++ b/v2/src/bin/sitemap
@@ -0,0 +1,72 @@
+#!/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'