backlinks: provide additional parameter btitle

This commit is contained in:
Helmut Merz 2023-07-14 09:13:14 +02:00
parent 76244a73da
commit 9051375a03
2 changed files with 7 additions and 6 deletions

View file

@ -4,19 +4,19 @@
{{- $url := "" -}} {{- $url := "" -}}
{{- $anchor := "" -}} {{- $anchor := "" -}}
{{- $btext := "" -}} {{- $btext := "" -}}
{{- $btitle := "" -}}
{{- if reflect.IsMap . -}} {{- if reflect.IsMap . -}}
{{- $anchor = .anchor -}} {{- $anchor = .anchor -}}
{{- $page = .page -}} {{- $page = .page -}}
{{- with .btext -}} {{- with .btext -}}{{- $btext = printf " (%s)" . -}}{{- end -}}
{{- $btext = printf " (%s)" . -}} {{- $btitle = .btitle -}}
{{- end -}}
{{- end -}} {{- end -}}
{{- if ne $anchor "" -}} {{- if ne $anchor "" -}}
{{- $url = printf "%s#%v" $page.Permalink $anchor -}} {{- $url = printf "%s#%v" $page.Permalink $anchor -}}
{{- else -}} {{- else -}}
{{- $url = $page.Permalink -}} {{- $url = $page.Permalink -}}
{{- end -}} {{- end -}}
<a href="{{ $url }}">{{ $page.Title }}{{ $btext }}&nbsp;&nbsp; <a href="{{ $url }}" title="{{ $btitle }}">{{ $page.Title }}{{ $btext }}&nbsp;&nbsp;
{{ if $page.Date -}} {{ if $page.Date -}}
<small>{{ $page.Date.Format (i18n "dateFormat") }}</small> <small>{{ $page.Date.Format (i18n "dateFormat") }}</small>
{{- else if $page.Params.Teaser -}}<small>{{ $page.Params.Teaser }}</small> {{- else if $page.Params.Teaser -}}<small>{{ $page.Params.Teaser }}</small>

View file

@ -6,6 +6,7 @@
{{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}} {{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}}
{{- $fragsep := cond (eq $frag "") "" "#" -}} {{- $fragsep := cond (eq $frag "") "" "#" -}}
{{- $btext := or (.Get "btext") (printf "%d" $linkid) -}} {{- $btext := or (.Get "btext") (printf "%d" $linkid) -}}
{{- $btitle := .Get "btitle" -}}
{{- $anchor := printf "link-%d" $linkid -}} {{- $anchor := printf "link-%d" $linkid -}}
{{- $inner := .Inner -}} {{- $inner := .Inner -}}
{{- range $pages -}} {{- range $pages -}}
@ -13,5 +14,5 @@
{{- $text := or $inner .Title -}} {{- $text := or $inner .Title -}}
<a id="{{ $anchor }}" <a id="{{ $anchor }}"
href="{{ $url }}">{{ $text | markdownify }}</a> href="{{ $url }}">{{ $text | markdownify }}</a>
{{- .Scratch.Add "backlinks" (slice (dict "anchor" $anchor "page" $this "btext" $btext)) -}} {{- .Scratch.Add "backlinks" (slice (dict "anchor" $anchor "page" $this "btext" $btext "btitle" $btitle)) -}}
{{- end -}} {{- end -}}