Summary Files Commits Branches @commit @diff @stats
path: root / generate.sh
diff options
context:
space:
mode:
1 files changed, 20 insertions, 0 deletions
-rwxr-xr-xgenerate.sh20
diff --git a/generate.sh b/generate.sh
index 2e9fd70..0bc2b5c 100755
--- a/generate.sh
+++ b/generate.sh
@@ -1,5 +1,7 @@
#!/bin/sh
+set -e
+
: ${SRC:=$PWD/src}
: ${DST:=./website}
: ${URL:=https://syndamia.com}
@@ -11,6 +13,19 @@
export SRC DST URL AWK HEADER FOOTER META
+#== 0. Check for changes ==#
+
+if [ -d "$DST" ] \
+ && [ -f "$DST/.commit" ] \
+ && command -v git >/dev/null 2>&1 \
+ && [ -z "$(git status -s)" ] \
+ && [ "$(cat "$DST"/.commit)" = "$(git rev-parse HEAD)" ]
+then
+ echo "Output '$DST' is up to date with website source '$SRC'!"
+ echo "Refusing to generate..."
+ exit 0
+fi
+
#== 1. Fix hardlinks ==#
while read -r folder
@@ -51,6 +66,11 @@ $AWK -f ./meta/meta.awk \
-v date="$(date +%Y-%m-%d)" \
$(find "$DST" -type f -name "*.html")
+if command -v git >/dev/null 2>&1
+then
+ git rev-parse HEAD > "$DST"/.commit
+fi
+
echo "[3/4] Added HTML header/footer, generated sitemap"
#== 4. Tiny version, strip away styles and other stuff ==#