{{- $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 -}} {{ with $prefix }}{{ markdownify . }} {{ end }}{{ $text | markdownify }} {{- .Scratch.Add "backlinks" (slice (dict "anchor" $anchor "page" $this "btext" $btext "btitle" $btitle)) -}} {{- end -}}