summaryrefslogtreecommitdiff
path: root/lib/template.source.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/template.source.sh')
-rw-r--r--lib/template.source.sh27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/template.source.sh b/lib/template.source.sh
index c4d054d..a8cc9ac 100644
--- a/lib/template.source.sh
+++ b/lib/template.source.sh
@@ -65,20 +65,21 @@ template::_line () {
}
# Can be used from a .gmi.tpl template for generating an index for a given topic.
-template::index () {
- local -r topic="$1"; shift
-
- while read -r gmi_file; do
- local date=$(cut -d- -f1,2,3 <<< "$gmi_file")
- local title=$($SED -n "/^# / { s/# //; p; q; }" "$gmi_file")
-
- local current=''
- if [ "$gmi_file" = "$CURRENT_GMI" ]; then
- current=" (You are currently reading this)"
- fi
+template::inline::index () {
+ local topic=''
+ for topic in "$@"; do
+ while read -r gmi_file; do
+ local date=$(cut -d- -f1,2,3 <<< "$gmi_file")
+ local title=$($SED -n "/^# / { s/# //; p; q; }" "$gmi_file")
+
+ local current=''
+ if [ "$gmi_file" = "$CURRENT_GMI" ]; then
+ current=" (You are currently reading this)"
+ fi
- echo "=> ./$gmi_file $date $title$current"
- done < <(ls | $GREP "$topic.*\\.gmi\$" | sort -r)
+ echo "=> ./$gmi_file $date $title$current"
+ done < <(ls | $GREP "$topic.*\\.gmi\$")
+ done | sort -r | uniq
}
template::test () {