diff options
| author | Nicholas Johnson <mail@nicholasjohnson.ch> | 2024-06-11 00:00:00 +0000 | 
|---|---|---|
| committer | Nicholas Johnson <mail@nicholasjohnson.ch> | 2024-06-11 00:00:00 +0000 | 
| commit | dec9d570fc72eb3035d1a8634bb4cafeda49d7bf2d5fe7017ffa088831214638 (patch) | |
| tree | 9cb5e255e2c0006657fe86f3c7502ae224b8257928ccef2cd522865567cc43aa /layouts/_default | |
| parent | cb61a83c8cbc201c4e6ac00a7f54fa96761190c8e1533b57f586e45582d54e06 (diff) | |
| download | hugo-theme-journal-dec9d570fc72eb3035d1a8634bb4cafeda49d7bf2d5fe7017ffa088831214638.tar.gz hugo-theme-journal-dec9d570fc72eb3035d1a8634bb4cafeda49d7bf2d5fe7017ffa088831214638.zip | |
Work around slices bug in Hugo v0.114.0 or newer
I used a slice of maps instead of a slice of slices, as recommended in
the Hugo issue tracking the bug:
https://github.com/gohugoio/hugo/issues/11131#issuecomment-1601769489
Diffstat (limited to 'layouts/_default')
| -rw-r--r-- | layouts/_default/single.gmi | 17 | 
1 files changed, 12 insertions, 5 deletions
| diff --git a/layouts/_default/single.gmi b/layouts/_default/single.gmi index c6b7356..2934781 100644 --- a/layouts/_default/single.gmi +++ b/layouts/_default/single.gmi @@ -36,10 +36,17 @@  		{{/* find all the links within a chunk */ -}}  		{{ $chunk_refs := findRESubmatch `!?\[[\t ]*(.+?)[\t ]*\]\([\t ]*(.+?)(?:[\t ]+"(.+?)")?[\t ]*\)` $rendered_text -}} -		{{ $scratch.Add "refs" $chunk_refs -}}  		{{ range $chunk_refs -}}  			{{ $ref_index = add $ref_index 1 -}} -			{{ $ref_text := index . 1 -}} +			{{ $chunk_ref := dict +				"text" (index . 1) +				"link" (index . 2) +				"title" (index . 3) +			-}} + +			{{ $scratch.Add "refs" (slice $chunk_ref) -}} + +			{{ $ref_text := $chunk_ref.text -}}  			{{/* create superscript of $ref_index */ -}}  			{{ $ref_index := replace $ref_index "0" "⁰" -}} @@ -106,9 +113,9 @@  ## {{ i18n "refs" }}  {{ range $refs -}}  	{{ $ref_index  = add $ref_index 1 -}} -	{{ $ref_text  := index . 1 -}} -	{{ $ref_link  := index . 2 -}} -	{{ $ref_title := index . 3 -}} +	{{ $ref_text  := .text -}} +	{{ $ref_link  := .link -}} +	{{ $ref_title := .title -}}  	{{/* render referenced links */}}  {{ print "=> " $ref_link (emojify " :link: [") $ref_index "]: " (cond (ne (len $ref_title) 0) $ref_title $ref_text) | safeHTML -}} | 
