add web mentions h2

This commit is contained in:
Ayo 2023-05-30 16:11:38 +02:00
parent 7009de21f4
commit d4a79d1303
3 changed files with 26 additions and 15 deletions

View file

@ -89,25 +89,17 @@
document.URL.replace("http://localhost:4000", "https://ayos.blog") document.URL.replace("http://localhost:4000", "https://ayos.blog")
); );
if (!ignore.includes(url.pathname)) { if (!ignore.includes(url.pathname)) {
console.log("url: ", url);
const mentions = getMentions(url.toString()) const mentions = getMentions(url.toString())
.then((mentions) => { .then((mentions) => {
const likes = mentions.filter((m) => m["wm-property"] === "like-of");
console.log("likes", likes);
if (likes.length)
document.getElementById(
"page-likes"
).innerHTML = `• ${likes.length} likes`;
const replies = mentions.filter( const replies = mentions.filter(
(m) => m["wm-property"] === "in-reply-to" (m) => m["wm-property"] === "in-reply-to"
); );
console.log("replies", replies);
if (replies.length) { if (replies.length) {
// render to post header meta // render to post header meta
const repliesSection = document.querySelector("section#replies");
document.getElementById( document.getElementById(
"page-replies" "page-replies"
).innerHTML = `• ${replies.length} replies`; ).innerHTML = `• <a href="#replies">${replies.length} replies</a>`;
// render to replies section // render to replies section
const repliesTable = document.createElement("table"); const repliesTable = document.createElement("table");
@ -131,21 +123,26 @@
cell.appendChild(replyBlock); cell.appendChild(replyBlock);
repliesTable.append(row); repliesTable.append(row);
}); });
document.querySelector("section#replies").append(repliesTable);
repliesSection.innerHTML = "<h2>Web Mentions:</h2>";
repliesSection.append(repliesTable);
} }
const likes = mentions.filter((m) => m["wm-property"] === "like-of");
if (likes.length)
document.getElementById(
"page-likes"
).innerHTML = `• ${likes.length} likes`;
const reposts = mentions.filter( const reposts = mentions.filter(
(m) => m["wm-property"] === "repost-of" (m) => m["wm-property"] === "repost-of"
); );
console.log("reposts", reposts);
if (reposts.length) if (reposts.length)
document.getElementById( document.getElementById(
"page-reposts" "page-reposts"
).innerHTML = `• ${reposts.length} reposts`; ).innerHTML = `• ${reposts.length} reposts`;
}) })
.catch((err) => console.log("err", err)); .catch((err) => console.log("err", err));
} else {
console.log("ignoring url: ", url);
} }
async function getMentions(url) { async function getMentions(url) {

View file

@ -1,9 +1,13 @@
<section id="replies"></section> <section id="replies"></section>
<style> <style>
section#replies {
margin: 1em 0;
}
.reply-block { .reply-block {
display: block; display: block;
margin: 1em 0; margin: 0 0 1em;
padding: 1em; padding: 1em;
border-left: 3px solid #ccc; border-left: 3px solid #ccc;
} }

View file

@ -41,6 +41,16 @@ body {
text-decoration: underline; text-decoration: underline;
text-decoration-thickness: 1px; text-decoration-thickness: 1px;
} }
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: "Source Serif Pro", serif;
font-weight: bold;
}
} }
.category-head { .category-head {