Created
May 7, 2018 16:19
-
-
Save martymcguire/b926bc11fce18283e2470a66965bfb8a to your computer and use it in GitHub Desktop.
Rendering webmentions with Morris on wehavetoask.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="mentions" class="mentions"> | |
{{ $paths := union (slice .URL) .Params.aliases }} | |
{{ range $paths }} | |
{{ $mentions_for_path := index $.Site.Data.webmention_io.index . }} | |
{{ if $mentions_for_path }} | |
{{ $.Scratch.Add "mention_ids" $mentions_for_path }} | |
{{ end }} | |
{{ end }} | |
{{ $mention_ids := $.Scratch.Get "mention_ids" }} | |
{{ $mentions := apply $mention_ids "index" $.Site.Data.webmention_io.mentions "." }} | |
{{ $mentions := sort $mentions "wm-received" }} | |
{{ $likes := where $mentions "wm-property" "like-of" }} | |
{{ $reposts := where $mentions "wm-property" "in" (slice "repost-of" "in-reply-to") }} | |
{{ $mentions := where $mentions "wm-property" "not in" (slice "like-of" "repost-of" "in-reply-to" ) }} | |
{{ if $likes }} | |
<h3>Likes</h3> | |
<div class="likes"> | |
{{ range $likes }} | |
{{ partial "episode_discussion_like.html" . }} | |
{{ end }} | |
</div> | |
{{ end }} | |
{{ if $reposts }} | |
<h3>Reposts</h3> | |
{{ range $reposts }} | |
{{ partial "episode_discussion_repost.html" . }} | |
{{ end }} | |
{{ end }} | |
{{ if $mentions }} | |
<h3>Mentions</h3> | |
{{ range $mentions }} | |
{{ partial "episode_discussion_repost.html" . }} | |
{{ end }} | |
{{ end }} | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="like"> | |
<div class="author"> | |
<a href="{{ .url }}"> | |
<img class="avatar" src="{{ .author.photo }}" alt="{{ .author.name }} likes this" title="{{ .author.name }} likes this"/> | |
</a> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="repost"> | |
<div class="author"> | |
<a href="{{ .author.url }}"> | |
<img class="avatar" src="{{ .author.photo }}" alt="{{ .author.name }}" t | |
itle="{{ .author.name }}"/> | |
</a> | |
</div> | |
<div class="repost-content"> | |
<div class="author-name"><a href="{{ .url }}">{{ .author.name }} mentioned | |
this:</a></div> | |
<blockquote> | |
{{ .content.text }} | |
</blockquote> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment