commit 6b49431f10551571ec6809eeca3e74fa84552d74 (patch) parent 2832c3f157864dd88333dc97b0725335a3955f73 Author: Alex Karle <alex@alexkarle.com> Date: Mon, 4 Nov 2024 02:05:23 +0100 Update nav to be dynamic based on page I feel like I had this code a LONG time ago Diffstat:
M | bin/genpage | | | 28 | ++++++++++++++++++++-------- |
1 file changed, 20 insertions(+), 8 deletions(-)
diff --git a/bin/genpage b/bin/genpage @@ -25,24 +25,36 @@ cat <<EOM </head> <body> <nav> -<a href="/">Home</a> | -<a href="/blog">Blog</a> | -<a href="/license.html">License</a> -</nav> EOM +dir=$(dirname "/$1") +if [ $(basename "$1") = "index.txt" ]; then + dir=$(dirname $dir) +fi + +while [ "$dir" != "/" ]; do + part=$(basename $dir) + path=${dir##/www} + if [ -z "$path" ]; then + path="/" + fi + echo " / <a href=\"$path\">$part</a>" | sed 's/www/home/' + dir=$(dirname $dir) +done | sed -n '1!G;h;$p' # reverse lines + +echo '</nav>' + nihdoc < "$1" -if echo "$1" | grep -q -v "index.txt"; then - cat <<EOM +cat <<EOM <footer> <br> -<em>Last Updated: $(git -C "$GITDIR" log --pretty="%cs" -n 1 -- "$1")</em> +<em>Last Updated: $(git -C "$GITDIR" log --pretty="%cs" -n 1 -- "$1") +(<a href="/license.html">License</a>)</em> </footer> </body> </html> EOM -fi cat <<EOM </body>