`
const child = DOMPurify.sanitize(comment, {'RETURN_DOM_FRAGMENT': true});
const links = child.querySelectorAll('.tootlink');
for (const link of links) {
- link.onclick = function() { return copyToClipboard(this); }
+ link.onclick = function() { return copyElementTextToClipboard(this); }
}
parentElement.appendChild(child);
}
}
+let MASTODON_POST_ID
+
document.addEventListener("DOMContentLoaded", async (event) => {
+ let url, isComments
+ const isBot = /bot|google|baidu|bing|msn|teoma|slurp|yandex/i
+ .test(navigator.userAgent)
if (document.getElementsByClassName('gh-sidebar').length > 0) {
- const element = document.getElementById('mastodon-comments-list')
- const response = await fetch(`https://${MASTODON_HOST}/api/v1/accounts/${MASTODON_ACCOUNT_ID}/statuses?exclude_replies=true&exclude_reblogs=true`)
- const content = await response.json()
- return renderMastodonContent(content, element)
+ url = `https://${MASTODON_HOST}/api/v1/accounts/${MASTODON_ACCOUNT_ID}/statuses?exclude_replies=true&exclude_reblogs=true`
+ }
+ if (MASTODON_POST_ID && !isBot) {
+ url = `https://${MASTODON_HOST}/api/v1/statuses/${MASTODON_POST_ID}/context`
+ isComments = true
+ }
+ const element = document.getElementById('mastodon-comments-list')
+ if (url && element) {
+ const linkElement = document.getElementById('toot-link-top')
+ const clipElement = document.getElementById('toot-link-clip')
+ const tootUrl = `https://${MASTODON_HOST}/@s/${MASTODON_POST_ID}`
+ if (linkElement) {
+ linkElement.href = tootUrl
+ }
+ if (clipElement) {
+ clipElement.innerText = tootUrl
+ }
+ const response = await fetch(url)
+ let content = await response.json()
+ if (isComments) {
+ content = content.descendants
+ }
+ const header = document.getElementById('mastodon-comments-header')
+ if (header) {
+ header.style.display = ''
+ }
+ return renderMastodonContent(content, element, isComments)
}
})
diff --git a/default.hbs b/default.hbs
index e760532..d353938 100644
--- a/default.hbs
+++ b/default.hbs
@@ -6,7 +6,11 @@
-
+
{{> "components/navigation" navigationLayout=@custom.navigation_layout}}
{{{body}}}
-
+
{{> "components/footer"}}
-
+
{{#is "post, page"}}
diff --git a/post.hbs b/post.hbs
index de7d367..193c384 100644
--- a/post.hbs
+++ b/post.hbs
@@ -50,6 +50,21 @@
+
+
+
{{#if comments}}