Integrate Webmentiond
This commit is contained in:
parent
8c9fff73fa
commit
30e253199a
|
@ -0,0 +1,17 @@
|
|||
async function displayWebmentions() {
|
||||
let endpoint = '{{ .Param "indieweb.endpoints.webmentiond" }}';
|
||||
let target = window.location.href;
|
||||
let resp = await fetch(`${endpoint}get?target=${target}`);
|
||||
let data = await resp.json();
|
||||
let mentionsListView = document.querySelector('#mentionslist');
|
||||
let list = document.createElement('ul');
|
||||
data.forEach(mention => {
|
||||
let listItem = document.createElement('li');
|
||||
listItem.innerHTML = `<a href="${mention.source}" target="_blank" rel="nofollow noopener noreferrer">${mention.author_name ? mention.author_name : mention.source}</a>${mention.title ? ` <i>${mention.title}</i>` : ''}`;
|
||||
list.appendChild(listItem);
|
||||
});
|
||||
mentionsListView.innerHTML = ``;
|
||||
mentionsListView.appendChild(list);
|
||||
}
|
||||
|
||||
displayWebmentions();
|
|
@ -1,17 +1,12 @@
|
|||
{{ if .Param "indieweb.enabled" }}
|
||||
{{ if not (.Param "indieweb.hidewmform") }}
|
||||
{{ if .Param "indieweb.endpoints.webmention" }}
|
||||
{{ $md5pl := md5 (replace .Permalink "/" "") }}
|
||||
{{ $mentions := index .Site.Data.mentions $md5pl }}
|
||||
{{ $dateFormat := ( .Site.Params.dateformat | default "January 02, 2006") }}
|
||||
<details class="p" id="interactions">
|
||||
<summary><b>{{ T "interactions" }}</b></summary>
|
||||
{{ with $mentions }}
|
||||
<ul>
|
||||
{{ range sort . ".date" "asc" }}{{ $sourceUrl := urls.Parse .source }}
|
||||
<li><a href="{{ .source }}" target="_blank" rel="nofollow noopener noreferrer">{{ $sourceUrl.Host }}</a> <i>{{ dateFormat $dateFormat .date }}</i></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ if .Param "indieweb.endpoints.webmentiond" }}
|
||||
<div id="mentionslist"></div>
|
||||
{{ $wmScript := resources.Get "js/webmentions.template.js" | resources.ExecuteAsTemplate "js/webmentions.js" . | minify | fingerprint }}
|
||||
<script defer src="{{ $wmScript.RelPermalink }}" integrity="{{ $wmScript.Data.Integrity }}"></script>
|
||||
{{ end }}
|
||||
<form method="post" action="{{ .Param "indieweb.endpoints.webmention" }}">
|
||||
<label for="wm-source" class="p">{{ T "wmform_label" }}</label>
|
||||
|
|
Reference in New Issue