Commit e9e8541c authored by Jamie Tanna's avatar Jamie Tanna

Fix: Render webmentions count + form even if no webmentions

A slight oversight - without this, we wouldn't note how many
interactions we had (even if 0) as well as not showing the HTML form for
a manual webmention.
parent 3eab7827
{{ $url := printf "%s%s" .Site.Params.LiveSiteUrl .URL }}
{{ $webmentions := getJSON (printf .Site.Params.WebMentionFormatUrl $url) }}
{{ if gt (len $webmentions.children) 0 }}
{{ $likes := slice }}
{{ $reposts := slice }}
{{ $replies := slice }}
{{ $mentions := slice }}
{{ $bookmarks := slice }}
{{ $rsvps := slice }}
{{ range $webmentions.children }}
{{ if eq "like-of" (index . "wm-property") }}
{{ $likes = $likes | append . }}
{{ end }}
{{ if eq "repost-of" (index . "wm-property") }}
{{ $reposts = $reposts | append . }}
{{ end }}
{{ if eq "in-reply-to" (index . "wm-property") }}
{{ $replies = $replies | append . }}
{{ end }}
{{ if eq "mention-of" (index . "wm-property") }}
{{ $mentions = $mentions | append . }}
{{ end }}
{{ if eq "bookmark-of" (index . "wm-property") }}
{{ $bookmarks = $bookmarks | append . }}
<div class="webmentions">
<h2>Interactions with this post</h2>
<p>This post has had {{ len $webmentions.children }} <a href="http://indieweb.org/webmention">WebMention</a> interactions, as of {{ now.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}.</p>
<div class="manual-webmention">
<p>Have you written a <a href="https://indieweb.org/responses">response</a> to this post? Let me know the URL:</p>
<form id="manual-webmention" action="https://webmention.io/{{ .Site.Params.WebMentionDomain }}/webmention" method="post">
<input type="url" name="source" value="" />
<input type="hidden" name="target" value="{{ $url }}" />
<input type="submit" name="submit" value="Send Webmention" />
</form>
</div>
{{ if gt (len $webmentions.children) 0 }}
{{ $likes := slice }}
{{ $reposts := slice }}
{{ $replies := slice }}
{{ $mentions := slice }}
{{ $bookmarks := slice }}
{{ $rsvps := slice }}
{{ range $webmentions.children }}
{{ if eq "like-of" (index . "wm-property") }}
{{ $likes = $likes | append . }}
{{ end }}
{{ if eq "repost-of" (index . "wm-property") }}
{{ $reposts = $reposts | append . }}
{{ end }}
{{ if eq "in-reply-to" (index . "wm-property") }}
{{ $replies = $replies | append . }}
{{ end }}
{{ if eq "mention-of" (index . "wm-property") }}
{{ $mentions = $mentions | append . }}
{{ end }}
{{ if eq "bookmark-of" (index . "wm-property") }}
{{ $bookmarks = $bookmarks | append . }}
{{ end }}
{{ if eq "rsvp" (index . "wm-property") }}
{{ $rsvps = $rsvps | append . }}
{{ end }}
{{ end }}
{{ if eq "rsvp" (index . "wm-property") }}
{{ $rsvps = $rsvps | append . }}
{{ end }}
{{ partial "webmention/likes.html" $likes }}
{{ partial "webmention/mentions.html" $mentions }}
{{ partial "webmention/reposts.html" $reposts }}
{{ partial "webmention/replies.html" $replies }}
{{ partial "webmention/bookmarks.html" $bookmarks }}
{{ partial "webmention/rsvps.html" $rsvps }}
{{ end }}
<div class="webmentions">
<h2>Interactions with this post</h2>
<p>This post has had {{ len $webmentions.children }} <a href="http://indieweb.org/webmention">WebMention</a> interactions, as of {{ now.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}.</p>
<div class="manual-webmention">
<p>Have you written a <a href="https://indieweb.org/responses">response</a> to this post? Let me know the URL:</p>
<form id="manual-webmention" action="https://webmention.io/{{ .Site.Params.WebMentionDomain }}/webmention" method="post">
<input type="url" name="source" value="" />
<input type="hidden" name="target" value="{{ $url }}" />
<input type="submit" name="submit" value="Send Webmention" />
</form>
</div>
{{ partial "webmention/likes.html" $likes }}
{{ partial "webmention/mentions.html" $mentions }}
{{ partial "webmention/reposts.html" $reposts }}
{{ partial "webmention/replies.html" $replies }}
{{ partial "webmention/bookmarks.html" $bookmarks }}
{{ partial "webmention/rsvps.html" $rsvps }}
</div>
{{ end }}
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment