diff options
| author | Paul Buetow <paul@buetow.org> | 2023-03-24 12:13:47 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-03-24 12:13:47 +0200 |
| commit | 9cdd770ac428eaef43af8bd5532f127df825999a (patch) | |
| tree | 0dc9d1ad40f63a4a0b91385cdee3d36062cd41cf | |
| parent | 57759ff94148a3329bcf651647734eed2a7751b4 (diff) | |
can specify multiple index topics for template::inline::index
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | lib/template.source.sh | 27 |
2 files changed, 18 insertions, 16 deletions
@@ -150,17 +150,18 @@ Another thing you can do is to insert an index with links to similar blog posts. ``` See more entries about DTail: -<< template::index dtail +<< template::inline::index dtail golang Blablabla... ``` -... scans all other post entries with `dtail` in the file name and generates a link list like this: +... scans all other post entries with `dtail` and `golang` in the file name and generates a link list like this: ``` -See more entries about DTail: +See more entries about DTail and Golang: => ./2022-10-30-installing-dtail-on-openbsd.gmi 2022-10-30 Installing DTail on OpenBSD +=> ./2022-04-22-programming-golang.gmi 2022-04-22 The Golang Programming language => ./2022-03-06-the-release-of-dtail-4.0.0.gmi 2022-03-06 The release of DTail 4.0.0 => ./2021-04-22-dtail-the-distributed-log-tail-program.gmi 2021-04-22 DTail - The distributed log tail program (You are currently reading this) 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 () { |
