From 3c1f7fdf563b6b550d902f4ef6f77e2f336d3e62 Mon Sep 17 00:00:00 2001 From: James Mills <1290234+prologic@users.noreply.github.com> Date: Thu, 30 Mar 2023 22:53:03 +1000 Subject: [PATCH] Add list plugin to contrib --- contrib/plugins/list | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 contrib/plugins/list diff --git a/contrib/plugins/list b/contrib/plugins/list new file mode 100755 index 0000000..ace7f3d --- /dev/null +++ b/contrib/plugins/list @@ -0,0 +1,27 @@ +#!/bin/sh + +if [ ! $# = 1 ]; then + printf >&2 "Usage: %s [ext]\n" "$(basename "$0")" + exit 0 +fi + +p="$1" +t="${2:-md}" + +if [ ! -d "$p" ]; then + printf >&2 "error: path %s not found\n" "$p" + exit 1 +fi + +find "$p" -type f -name "*.$t" | while read -r file; do + name="${file#"$p"}" + name="${name#"/"}" + name="${name%.*}" + + title="$(zs vars "$file" title)" + if [ -z "$title" ]; then + title="$name" + fi + + echo "- [$title](${p}/${name}.html)" +done -- 2.43.0