backlinks: show link number

This commit is contained in:
Helmut Merz 2023-07-11 18:17:27 +02:00
parent 29ef9cc5ca
commit f56dbfd3a9
2 changed files with 5 additions and 2 deletions

View file

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

View file

@ -10,7 +10,8 @@
{{- $url := printf "%s%s%s" .Permalink $fragsep $frag -}}
{{- $text := or $inner .Title -}}
{{- $anchor := printf "link-%d" $linkid -}}
{{- $title := printf "%s (%d)" $this.Title $linkid -}}
<a id="{{ $anchor }}"
href="{{ $url }}">{{ $text | markdownify }}</a>
{{- .Scratch.Add "backlinks" (slice (dict "anchor" $anchor "page" $this)) -}}
{{- .Scratch.Add "backlinks" (slice (dict "anchor" $anchor "page" $this "title" $title)) -}}
{{- end -}}