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 .Param "indieweb.enabled" }}
|
||||||
{{ if not (.Param "indieweb.hidewmform") }}
|
{{ if not (.Param "indieweb.hidewmform") }}
|
||||||
{{ if .Param "indieweb.endpoints.webmention" }}
|
{{ 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">
|
<details class="p" id="interactions">
|
||||||
<summary><b>{{ T "interactions" }}</b></summary>
|
<summary><b>{{ T "interactions" }}</b></summary>
|
||||||
{{ with $mentions }}
|
{{ if .Param "indieweb.endpoints.webmentiond" }}
|
||||||
<ul>
|
<div id="mentionslist"></div>
|
||||||
{{ range sort . ".date" "asc" }}{{ $sourceUrl := urls.Parse .source }}
|
{{ $wmScript := resources.Get "js/webmentions.template.js" | resources.ExecuteAsTemplate "js/webmentions.js" . | minify | fingerprint }}
|
||||||
<li><a href="{{ .source }}" target="_blank" rel="nofollow noopener noreferrer">{{ $sourceUrl.Host }}</a> <i>{{ dateFormat $dateFormat .date }}</i></li>
|
<script defer src="{{ $wmScript.RelPermalink }}" integrity="{{ $wmScript.Data.Integrity }}"></script>
|
||||||
{{ end }}
|
|
||||||
</ul>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<form method="post" action="{{ .Param "indieweb.endpoints.webmention" }}">
|
<form method="post" action="{{ .Param "indieweb.endpoints.webmention" }}">
|
||||||
<label for="wm-source" class="p">{{ T "wmform_label" }}</label>
|
<label for="wm-source" class="p">{{ T "wmform_label" }}</label>
|
||||||
|
|
Reference in New Issue