summaryrefslogtreecommitdiff
path: root/layouts/_default
diff options
context:
space:
mode:
authorNicholas Johnson <mail@nicholasjohnson.ch>2024-06-11 00:00:00 +0000
committerNicholas Johnson <mail@nicholasjohnson.ch>2024-06-11 00:00:00 +0000
commit17077bcfbc585dc22d75cbe0d594e011041568ac6f81b5ae20afedf2e0ca3886 (patch)
treeadf5f389d250c4a7cf2476fbedbcf3112739a741d78e1c4d7a926512c882faf8 /layouts/_default
parentdec9d570fc72eb3035d1a8634bb4cafeda49d7bf2d5fe7017ffa088831214638 (diff)
downloadhugo-theme-journal-17077bcfbc585dc22d75cbe0d594e011041568ac6f81b5ae20afedf2e0ca3886.tar.gz
hugo-theme-journal-17077bcfbc585dc22d75cbe0d594e011041568ac6f81b5ae20afedf2e0ca3886.zip
Save link index in map
This removes the need to recount.
Diffstat (limited to 'layouts/_default')
-rw-r--r--layouts/_default/single.gmi8
1 files changed, 4 insertions, 4 deletions
diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi
index 2934781..c9b6896 100644
--- a/layouts/_default/single.gmi
+++ b/layouts/_default/single.gmi
@@ -37,8 +37,8 @@
{{ $chunk_refs := findRESubmatch `!?\[[\t ]*(.+?)[\t ]*\]\([\t ]*(.+?)(?:[\t ]+"(.+?)")?[\t ]*\)` $rendered_text -}}
{{ range $chunk_refs -}}
- {{ $ref_index = add $ref_index 1 -}}
{{ $chunk_ref := dict
+ "index" (add $ref_index 1)
"text" (index . 1)
"link" (index . 2)
"title" (index . 3)
@@ -46,6 +46,7 @@
{{ $scratch.Add "refs" (slice $chunk_ref) -}}
+ {{ $ref_index := $chunk_ref.index -}}
{{ $ref_text := $chunk_ref.text -}}
{{/* create superscript of $ref_index */ -}}
@@ -106,13 +107,12 @@
{{ end -}}
{{ $refs := $scratch.Get "refs" -}}
-{{ if and (.Page.Params.makerefs | default true) $refs -}}
-{{ $ref_index := 0 }}
+{{ if and (.Page.Params.makerefs | default true) $refs }}
## {{ i18n "refs" }}
{{ range $refs -}}
- {{ $ref_index = add $ref_index 1 -}}
+ {{ $ref_index := .index -}}
{{ $ref_text := .text -}}
{{ $ref_link := .link -}}
{{ $ref_title := .title -}}