adityatelange / hugo-PaperMod

A fast, clean, responsive Hugo theme.
https://adityatelange.github.io/hugo-PaperMod/
MIT License
9.53k stars 2.58k forks source link

Add support for Fediverse comments #1457

Open pierreprinetti opened 5 months ago

pierreprinetti commented 5 months ago

How to add Fediverse comments

In a post where to allow Fediverse comments:

comments:
  fediverse:
    url: https://example.com/@handle/123456789012345678

All replies to the Fediverse post will appear as comments.

Moderation

By default, the moderation system is opt-out. All replies will be published unless they are individually hidden.

To hide one specific Fediverse post:

comments:
  fediverse:
    url: https://example.com/@handle/123456789012345678
    hidden:
    - https://example.com/@troll/123456789012345679

To switch to opt-in moderation, where only accepted posts are shown:

comments:
  fediverse:
    url: https://example.com/@handle/123456789012345678
    moderation: opt-in
    shown:
    - https://example.com/@friend/123456789012345680

The JavaScript for the comments is based on yidhra's work, combined with Daniel Pecos Martinez's work for the Hugo version, as pupularized by Jan Wildeboer. It also includes changes by me.

What does this PR change? What problem does it solve?

This PR adds support for Fediverse comments. Any replies to the given Fediverse post will appear as comments under your Hugo article.

Was the change discussed in an issue or in the Discussions before?

No. This is code that I use on a PaperMod fork on my website and I am proposing it back upstream just in case maintainers are interested.

I am aware that this code can't be merged as-is as it currently fetches an external library from the Cloudflare CDN. If the maintainers are interested in the functionality, I am happy to vendor the library and make other required changes.

PR Checklist

sonarcloud[bot] commented 5 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

shombando commented 5 months ago

@pierreprinetti this is great, looking forward to this getting merged!

zeeZ commented 3 months ago

Should probably be comments.mastodon to avoid confusion, since this requires Mastodon (compatible) API.

pierreprinetti commented 3 months ago

@adityatelange Are you interested in merging this, if I remove external resources and rename to comments.mastodon?

shombando commented 3 months ago

@pierreprinetti what's your workflow? Publish the post, created a mastodon post, edit and republish the post with the Mastodon url? I really like this feature, thanks for including all the links to prior work and to your great blog!

pierreprinetti commented 3 months ago

@pierreprinetti what's your workflow? Publish the post, created a mastodon post, edit and republish the post with the Mastodon url?

Precisely, yes. I publish, then post on Mastodon, then edit the post’s front matter. Thanks!

I got the idea from Jan Wildeboer, who got it (alongside the code) from here. I should add these credits in the PR actually.