From 17077bcfbc585dc22d75cbe0d594e011041568ac6f81b5ae20afedf2e0ca3886 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Tue, 11 Jun 2024 00:00:00 +0000 Subject: Save link index in map This removes the need to recount. --- layouts/_default/single.gmi | 8 ++++---- 1 file 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 -}} -- cgit v1.2.3