From 41a6d16ef6a356bc286b0eafe267d04aeed174f3 Mon Sep 17 00:00:00 2001 From: delta Date: Mon, 3 Feb 2025 22:58:46 +0100 Subject: initial commit --- .zs/generate_nav | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 .zs/generate_nav (limited to '.zs/generate_nav') diff --git a/.zs/generate_nav b/.zs/generate_nav new file mode 100755 index 0000000..28289af --- /dev/null +++ b/.zs/generate_nav @@ -0,0 +1,27 @@ +#!/bin/sh + +echo "/:home /projects.html:projects /posts.html:ramblings" | awk ' +function normalize(file) { + sub(".[^.]*$", "", file) + sub(".*/", "", file) + return file +} + +{ + for (i=1; i<=NF; i++) { + match($i, /:.+/) + name = substr($i, RSTART+1, RLENGTH) + + match($i, /.+:/) + file = substr($i, RSTART, RLENGTH-1) + + parsed_file = ENVIRON["ZS_FILE"] + + if (normalize(file) == normalize(parsed_file) || (normalize(parsed_file) == "index" && file == "/")) { + name = sprintf("[%s]", name) + } + + printf "
  • %s
  • ", file, name + if (i