diff --git a/assets/css/style.css b/assets/css/style.css index f8eabab..eeaac4e 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -215,3 +215,5 @@ nav li { .title { font-family: 'Comfortaa'; } + +#webmentions img { max-height: 1.2em; margin-right: -1ex; } diff --git a/assets/js/webmention.min.js b/assets/js/webmention.min.js new file mode 100644 index 0000000..f46daea --- /dev/null +++ b/assets/js/webmention.min.js @@ -0,0 +1 @@ +!function(){"use strict";window.i18next=window.i18next||{t:function(n){return n}};const n=window.i18next.t.bind(window.i18next);function t(n,t){return document.currentScript.getAttribute("data-"+n)||t}const e=t("page-url",window.location.href.replace(/#.*$/,"")),o=t("add-urls",void 0),r=t("id","webmentions"),s=t("wordcount"),i=t("max-webmentions",30),l=t("prevent-spoofing")?"wm-source":"url",c=t("sort-by","published"),a=t("sort-dir","up"),u=t("comments-are-reactions"),p={"in-reply-to":n("replied"),"like-of":n("liked"),"repost-of":n("reposted"),"bookmark-of":n("bookmarked"),"mention-of":n("mentioned"),rsvp:n("RSVPed"),"follow-of":n("followed")},f={"in-reply-to":"💬","like-of":"❤️","repost-of":"🔄","bookmark-of":"⭐️","mention-of":"💬",rsvp:"📅","follow-of":"🐜"},d={yes:"✅",no:"❌",interested:"💡",maybe:"💭"};function m(n){return n.replace(/&/g,"&").replace(//g,">").replace(/"/g,""")}function h(t,e){const o=m(t.author?.name??t.url.split("/")[2]);let r=p[t["wm-property"]]||n("reacted");!e&&t.content&&t.content.text&&(r+=": "+g(t));let s="";t.author&&t.author.photo&&(s=`\n \n `);let i="";return t.rsvp&&d[t.rsvp]&&(i=`${d[t.rsvp]}`),`\n \n ${s}\n ${f[t["wm-property"]]||"💥"}\n ${i}\n \n `}function w(n){return n.substr(n.indexOf("//"))}function $(n){const t=[],e={};return n.forEach((function(n){const o=w(n.url);e[o]||(t.push(n),e[o]=!0)})),t}function g(n){let t=m(n.content.text);if(s){let n=t.replace(/\s+/g," ").split(" ",s+1);n.length>s&&(n[s-1]+="…",n=n.slice(0,s),t=n.join(" "))}return t}window.addEventListener("load",(async function(){const t=document.getElementById(r);if(!t)return;const s=[w(e)];o&&o.split("|").forEach((function(n){s.push(w(n))}));let p=`https://webmention.io/api/mentions.jf2?per-page=${i}&sort-by=${c}&sort-dir=${a}`;s.forEach((function(n){p+=`&target[]=${encodeURIComponent("http:"+n)}&target[]=${encodeURIComponent("https:"+n)}`}));let f={};try{const n=await window.fetch(p);n.status>=200&&n.status<300?f=await n.json():(console.error("Could not parse response"),new Error(n.statusText))}catch(n){console.error("Request failed",n)}let d=[];const b=[];u&&(d=b);const y={"in-reply-to":d,"like-of":b,"repost-of":b,"bookmark-of":b,"follow-of":b,"mention-of":d,rsvp:d};f.children.forEach((function(n){const t=y[n["wm-property"]];t&&t.push(n)}));let k="";d.length>0&&d!==b&&(k=function(t){return`\n

${n("Responses")}

\n \n `}($(d)));let x="";var v;b.length>0&&(v=$(b),x=`\n

${n("Reactions")}

\n \n `),t.innerHTML=`${k}${x}`}))}(); \ No newline at end of file diff --git a/layouts/blog/single.html b/layouts/blog/single.html index 8b58ce3..d4b3db2 100644 --- a/layouts/blog/single.html +++ b/layouts/blog/single.html @@ -5,7 +5,7 @@ {{ if not .Date.IsZero }} {{ $singlePageDateFormat := .Site.Params.singlePageDateFormat | default "January 2, 2006"}} -

+

Published on

{{ end }} @@ -24,6 +24,15 @@ {{ .Content }} +
+
+

Have you published a response to this? :

+ + + +
+ {{ $webmentionjs := resources.Get "js/webmention.min.js" }} +