mirror of
https://git.mills.io/prologic/zs
synced 2025-04-02 21:06:14 +03:00
Add list plugin to contrib
This commit is contained in:
parent
71e45638de
commit
3c1f7fdf56
1 changed files with 27 additions and 0 deletions
27
contrib/plugins/list
Executable file
27
contrib/plugins/list
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ ! $# = 1 ]; then
|
||||
printf >&2 "Usage: %s <path> [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
|
Loading…
Add table
Reference in a new issue