20 lines
973 B
HTML
20 lines
973 B
HTML
{{- $pid := or (.Get "pid") (.Get "page") -}}
|
|
{{- $frag := or (.Get "id") (.Get "anchor") -}}
|
|
{{- $this := $.Page -}}
|
|
{{- $linkid := or ($this.Scratch.Get "linkid") 1 -}}
|
|
{{- $this.Scratch.Set "linkid" (add $linkid 1) -}}
|
|
{{- $pages := where .Site.Pages "Params.pageid" "eq" $pid -}}
|
|
{{- $fragsep := cond (eq $frag "") "" "#" -}}
|
|
{{- $btext := or (.Get "btext") (printf "%d" $linkid) -}}
|
|
{{- $btitle := .Get "btitle" -}}
|
|
{{- $prefix := .Get "prefix" -}}
|
|
{{- $anchor := printf "link-%d" $linkid -}}
|
|
{{- $inner := .Inner -}}
|
|
{{- $linkTitle := (.Get "title") -}}
|
|
{{- range $pages -}}
|
|
{{- $url := printf "%s%s%s" .Permalink $fragsep $frag -}}
|
|
{{- $text := or $inner .Title -}}
|
|
<a id="{{ $anchor }}"{{ with $linkTitle }} title="{{ . }}"{{ end }}
|
|
href="{{ $url }}">{{ with $prefix }}{{ markdownify . }} {{ end }}{{ $text | markdownify }}</a>
|
|
{{- .Scratch.Add "backlinks" (slice (dict "anchor" $anchor "page" $this "btext" $btext "btitle" $btitle)) -}}
|
|
{{- end -}}
|