welpo / tabi

A modern Zola theme with search, multilingual support, optional JavaScript, a perfect Lighthouse score, and a focus on accessibility.
https://welpo.github.io/tabi/
MIT License
97 stars 31 forks source link

Option for Fediverse (Mastodon) comments? #334

Open grifferz opened 1 week ago

grifferz commented 1 week ago

Thanks for this theme. I am very much enjoying making sites with it!

Feature Request

Provide a means to embed a Fediverse (Mastodon) conversation in a page, typically the thread of comments related to a post about the article itself.

Summary

As an alternative to the four existing commenting systems, would you consider adding a view of comments from an associated Fediverse post, such as this existing implementation?

Motivation

All of the existing commenting systems that have been implemented by tabi require commenters to log in to a centralised service, for example GitHub or yet another third party system (even if it is one that the site owner self-hosts like Isso).

Although not everyone has a Fediverse account, it is at least possible for anyone to have one without signing up to a specific service. If a commenter really wants to they can even self-host a Fediverse instance.

It is common to post a notification link about a new blog post or article onto a service like Mastodon, so it's natural for people who became aware of the article to respond on Fedi with their thoughts and comments. If these then are displayed on the article as well then it can bring a fuller experience to site visitors who would ordinarily never go onto the Fediverse to see that conversation.

Detailed Description

Using the linked webcomponent as an example, the way I see it working is something like:

  1. Author writes article as normal
  2. Author posts link to Fedi either manually or by some automated means
  3. Author takes the toot id from that Fedi post and updates the article with whatever tabi shortcode that would be equivalent to the HTML:
<mastodon-comments host="fosstodon.org" user="dpecos" tootId="109574160582937075" style="width : 1024px"></mastodon-comments>

That would embed the display of the conversation rooted at https://fosstodon.org/@dpecos/109574160582937075

Of course, if host and user are set in configuration then the actual shortcode would be a lot smaller as the only variable that would need to change per-page would be the toot ID.

The need to update the post with a directive containing the toot ID is a bit clunky but conceptually similar to the problem you discuss with social media cards, in that you are there looking to update the card image path in the frontmatter after the initial post was made; here looking to update a toot ID after a Fedi post related to the post is made.

Perhaps instead of a shortcode it could be triggered by placing a setting in the [extra] section, and then the same technique of using a script to update the frontmatter could be used. That is probably more suited to automation than having to put a shortcode somewhere in the article, and I guess you would always expect the conversation to be at the bottom anyway.

So now that I think more about it, having it as a config setting is probably more sensible in most cases, but additionally having a shortcode for it would probably still be desirable as that would bring the nice possibility of being able to embed multiple Fedi posts and optionally their comment threads.

What do you think?

I'm afraid that doing this work myself is beyond me, so I will just end up using the suggested webcomponent directly from a shortcode. It just seemed a nice feature that could be built in to tabi.

welpo commented 1 week ago

All of the existing commenting systems that have been implemented by tabi require commenters to log in to a centralised service

Just noting Isso allows anonymous comments: all fields are optional by default, and no account is needed.

Perhaps instead of a shortcode it could be triggered by placing a setting in the [extra] section, and then the same technique of using a script to update the frontmatter could be used.

That would be preferred for maintenance, yeah. Also using a specific [extra] section in config.toml.

additionally having a shortcode for it would probably still be desirable as that would bring the nice possibility of being able to embed multiple Fedi posts and optionally their comment threads

Can you elaborate? My idea would be as you mentioned: publish a post, mention this on the Fediverse, and use that thread as the comments of the post. In what instance might one want two separate comment sections?


I would be happy to add this to tabi. Indeed, I almost implemented this myself, but I decided four comment systems were enough :)

However, I had bookmarked a nice guide for Hugo. This could serve as a nice reference to implement the feature on tabi.

I'm afraid that doing this work myself is beyond me

Even after looking at the post/guide above? I can't prioritise working (solo) on this feature right now, but I'd be happy to complete a PR or provide guidence along the way!

grifferz commented 1 week ago

additionally having a shortcode for it would probably still be desirable as that would bring the nice possibility of being able to embed multiple Fedi posts and optionally their comment threads

Can you elaborate? My idea would be as you mentioned: publish a post, mention this on the Fediverse, and use that thread as the comments of the post. In what instance might one want two separate comment sections?

Oh, it's a secondary thing and not really very important, it's just that as you would have access to settings for the mastodon server and user anyway, then when given a toot id you can request that from the mastodon API and just not iterate through all the comments on it. It would be for the purpose of citing a toot in the article.

Anyway it's not important, I was just thinking that once there is already code to request a toot and its comments from a mastodon API then there may as well be a shortcode to request just the toot text for citing.

I would be happy to add this to tabi. Indeed, I almost implemented this myself, but I decided four comment systems were enough :)

Excellent!

However, I had bookmarked a nice guide for Hugo. This could serve as a nice reference to implement the feature on tabi.

This is not loading for me just now, but I have read it before and I was under the impression that both the person from the link I provided and also Carl Schwan were working from the same example javascript, it's just that Daniel Pecos had written it up a bit more extensively. You can see that Daniel gives a credit to Carl near the end of his post about it here:

https://danielpecos.com/2022/12/25/mastodon-as-comment-system-for-your-static-blog/

I think they're going to be basically the same approach so that's all good.

I'm afraid that doing this work myself is beyond me

Even after looking at the post/guide above? I can't prioritise working (solo) on this feature right now, but I'd be happy to complete a PR or provide guidence along the way!

I understand. I'm glad to read you have been thinking about it already at least. If anyone else is able to help I am ready to help with some testing.

welpo commented 1 week ago

It would be for the purpose of citing a toot in the article

Ah, gotcha! That would make sense as a shortcode, I think. I would do these (comments for a post / quoting a toot) separately.