diff --git a/.gitignore b/.gitignore index 364fdec..e292d34 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ public/ +.env diff --git a/config.toml b/config.toml index eb258d8..8914af1 100644 --- a/config.toml +++ b/config.toml @@ -55,6 +55,11 @@ keywords = "" favicon = "images/" pronouns = "he/him/his" feedSections =["article","note","photo","response"] + [params.comment] + [params.comment.fediverse] + enable=true + host = "gts.kelbie.scot" + user = "jon" [languages.en.Params] diff --git a/layouts/partials/mastodon/mastodon.html b/layouts/partials/mastodon/mastodon.html index a05e968..b49da78 100644 --- a/layouts/partials/mastodon/mastodon.html +++ b/layouts/partials/mastodon/mastodon.html @@ -1,17 +1,17 @@ -{{ with .Params.comments }} +

Comments

-

You can use your Mastodon account to reply to this post.

-

+

You can use your Mastodon account to reply to this post.

+

-

Reply to {{ .username }}'s post

+

Reply to {{ .Site.Params.comment.fediverse.user }}'s post

With an account on the Fediverse or Mastodon, you can respond to this post. Since Mastodon is decentralized, you can use your existing account hosted by another Mastodon server or compatible platform if you don't have an account on this one.

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

- +
@@ -27,7 +27,7 @@ }); document.getElementById('copyButton').addEventListener('click', () => { - navigator.clipboard.writeText('https://{{ .host }}/@{{ .username }}/statuses/{{ .id }}'); + navigator.clipboard.writeText('https://{{ .Site.Params.comment.fediverse.host }}/@{{ .Site.Params.comment.fediverse.user }}/statuses/{{ .Page.Params.comments.id }}'); }); document.getElementById('cancelButton').addEventListener('click', () => { @@ -57,7 +57,10 @@ document.getElementById("load-comment").addEventListener("click", function() { document.getElementById("load-comment").innerHTML = "Loading"; - fetch('https://{{ .host }}/api/v1/statuses/{{ .id }}/context') + require('dotenv').config(); + const key = process.env.API_KEY; + const headers = { 'Authorization': '${key}' }; // auth header with bearer token + fetch('https://{{ .Site.Params.comment.fediverse.host }}/api/v1/statuses/{{ .Page.Params.comments.id }}/context', { headers }) .then(function(response) { return response.json(); }) @@ -68,7 +71,7 @@ document.getElementById('mastodon-comments-list').innerHTML = ""; data['descendants'].forEach(function(reply) { reply.account.display_name = escapeHtml(reply.account.display_name); - reply.account.reply_class = reply.in_reply_to_id == "{{ .id }}" ? "reply-original" : "reply-child"; + reply.account.reply_class = reply.in_reply_to_id == "{{ .Page.Params.comments.id }}" ? "reply-original" : "reply-child"; reply.account.emojis.forEach(emoji => { reply.account.display_name = reply.account.display_name.replace(`:${emoji.shortcode}:`, `Emoji ${emoji.shortcode}`); @@ -103,4 +106,4 @@ });
-{{ end }} + diff --git a/themes/nipponalba/static/css/style.css b/themes/nipponalba/static/css/style.css index 029e71d..9a518d8 100644 --- a/themes/nipponalba/static/css/style.css +++ b/themes/nipponalba/static/css/style.css @@ -1159,7 +1159,7 @@ hr{ padding:0; } -#toggle_webmentions:checked + #webmentions_label, #toggle_comments:checked + #comments_label, #toggle_fediverse:checked + #fediverse_label{ +#toggle_webmentions:checked - #webmentions_label, #toggle_comments:checked + #comments_label, #toggle_fediverse:checked + #fediverse_label{ font-weight: bold; }