{{ $page := . }} {{ $currentPagePath := .RelPermalink }} {{ $webmentions_url := .Site.Params.webmention.src }} {{ with try (resources.GetRemote $webmentions_url) }} {{ with .Err }} {{ errorf "%s" . }} {{ else with .Value }} {{ $webmentions := slice }} {{ $data := . | transform.Unmarshal }} {{ range $data }} {{ $urlObj := urls.Parse .webmention.target }} {{ $targetPath := $urlObj.Path }} {{ if or (strings.Contains $targetPath $currentPagePath) (strings.Contains $targetPath ($currentPagePath | urlquery)) }} {{ $webmentions = $webmentions | append . }} {{ end }} {{ end }} {{ $likes := slice }} {{ $replies := slice }} {{ $reposts := slice }} {{ $mentions := slice }} {{ range $webmentions }} {{ $mf := index . "microformats" }} {{ if $mf }} {{ $type := index $mf "type" }} {{ if eq $type "like-of" }} {{ $likes = $likes | append . }} {{ else if eq $type "repost-of" }} {{ $reposts = $mentions | append . }} {{ else if eq $type "in-reply-to" }} {{ $replies = $replies | append . }} {{ else }} {{ $mentions = $mentions | append . }} {{ end }} {{ else }} {{ $mentions = $mentions | append . }} {{ end }} {{ end }} {{ if $webmentions }}
Unable to fetch webmentions. Please contact webmaster.
{{ end }} {{ end }}