blob: f397996d62ecf3dcc85b2edf792ba02e9baa9962 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
{{ $currentPagePath := .RelPermalink }}
{{ $webmentions := slice }}
{{ range .Site.Data.webmentions }}
{{ $urlObj := urls.Parse .webmention.target }}
{{ $targetPath := $urlObj.Path }}
{{ if or (strings.Contains $targetPath $currentPagePath)
(strings.Contains $targetPath ($currentPagePath | urlquery)) }}
{{ $webmentions = $webmentions | append . }}
{{ end }}
{{ end }}
<!--
some pages were moved, merge their webmention with old Data
-->
{{ $other_webmentions := where .Site.Data.webmentions "webmention.target" (printf "/posts%s" .RelPermalink ) }}
{{ if $other_webmentions }}
{{ $webmentions = $webmentions | union $other_webmentions }}
{{ end }}
{{ $likes := slice }}
{{ $replies := slice }}
{{ $reposts := slice }}
{{ $mentions := slice }}
{{ range $webmentions }}
{{ $props := index . "microformats" "properties" }}
{{ $type := index . "microformats" "type" 0 }}
{{ if eq $type "h-entry" }}
{{ if index $props "like-of" }}
{{ $likes = $likes | append . }}
{{ else if index $props "repost-of" }}
{{ $reposts = $mentions | append . }}
{{ else }}
{{ $replies = $replies | append . }}
{{ end }}
{{ else }}
{{ $mentions = $mentions | append . }}
{{ end }}
{{ end }}
{{ partial "posts/action-area" . }}
<details class="my-4 mb-5 no-mark">
<summary class="cursor-pointer flex">
{{ partial "posts/webmention-summary" (dict
"likes" $likes
"page" .
"othercount" (add (len $replies) (len $mentions))
) }}
</summary>
<div id="webmention-details">
{{ partial "posts/webmention-replies" $replies }}
{{ partial "posts/webmention-mentions" $mentions }}
</div>
<!-- kept for legacy pages -->
{{ partial "posts/comment" . }}
</details>
|