{{- $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.RegularPages "Params.pageid" "eq" $pid -}} {{- $fragsep := cond (eq $frag "") "" "#" -}} {{- $btext := or (.Get "btext") (printf "%d" $linkid) -}} {{- $btitle := .Get "btitle" -}} {{- $anchor := printf "link-%d" $linkid -}} {{- $inner := .Inner -}} {{- range $pages -}} {{- $url := printf "%s%s%s" .Permalink $fragsep $frag -}} {{- $text := or $inner .Title -}} {{ $text | markdownify }} {{- .Scratch.Add "backlinks" (slice (dict "anchor" $anchor "page" $this "btext" $btext "btitle" $btitle)) -}} {{- end -}}