Adding comments to this blog
5 February 2024 - by @mozzius.dev
This blog now has comments!
That might not sound particularly impressive, since I think most people would consider "comments on blogs" to be a Solved Problem. But I decided to go about it in a bit of a different way - all the comments are fetched directly from Bluesky. And I think the ease with which I did that goes a long way to demonstrating the power of Bluesky's Open Network, and is possibly worth talking about a little bit.
Bluesky is completely open
When I say "Bluesky is completely open", I really mean it. You don't even need an API key to query the AppView. Combined with the excellent tooling that Bluesky provides meant that implementating this feature took about hour, from scratch. Granted, I've been working with the API for a while now, but I think that's still pretty impressive.
Here's the code I used to fetch the comments (slightly simplified for clarity):
In the actual implementation, I don't use
BskyAgent
in favour of usingfetch
directly, due to Next.js overriding thefetch
function, but this version is a bit more readable and typesafe. And it's basically the same under the hood.
Simply make a <Comment />
component that renders a Bluesky post, and you're done! It's really that simple.
See my other blog post for a step-by-step guide on how to render a Bluesky post. My blog comments take it one step futher by rendering the replies recursively, to make a threaded comment section.
What this means
"The organization is a future adversary"
- Paul Frazee
Bluesky talks a lot about being "Billionaire-proof", and I think the open API is a critical part of that. Due to it's decentralised nature, it's not just open, it's "locked open" - Bluesky (the company) couldn't start locking off access even if they wanted to. This is in harsh contrast to X (formerly Twitter) turning off the free API, and making the paid API much more expensive, and Reddit suddenly charging 3rd party apps like Apollo $20 million a year for it's previously free API (instantly killing the 3rd party ecosystem).
This is critical to building trust in the platform among the developer community that Bluesky is trying to foster, and I think it's a big part of why Bluesky has seen an explosion of community projects. It's also a big part of why I'm so excited to be building on it. I don't have to worry that Bluesky will get bought out and "pull a Reddit" on me, because they literally can't. This matters, whether you want to add a little comment section to your blog, all the way up to building a full-fledged client.
I think this is also great for non-developers too. I completely stopped using Reddit when they killed Apollo, because the official app is garbage. That's not something you have to worry about with Bluesky, and it goes so much deeper than just the app. Every part of the platform can be swapped out, and that's a really powerful thing. We've watched platform after platform succumb to enshittification, and even if Bluesky (the company) follows suit, Bluesky (the community) doesn't have to.
This little comments section project - sure, it's pretty frivolous, but I love that Bluesky doesn't shy away from creativity. They want you to build cool things with what they've built. I think that's great.
Overall, I'm really optimistic about the future of Bluesky, and I'm excited to see what else is possible.
Let me know what you think in the all-new comments!
- Samuel (@mozzius.dev)
73 likes - 18 reposts
Comments
Comments are fetched directly from this post - reply there to add your own comment.
Shreyan @shreyanjain.net
pretty nice! Just FYI @snarfed.org is also running a service to make this kind of thing simple for other blogs
2
1
7
Graysky ☁️ @graysky.app
Oh neat, I didn’t release the scope of that project tbh @rebelalliancebriefingroom.kailejohansen.us is this closer to what you’re looking for?
1
0
3
Rebel Alliance Briefing Room @rebelalliancebriefingroom.kailejohansen.us
Well yes in a way. My "blog" is just a webpage I maintain. I edit and post the HTML myself. I do not use a blog site. and it is more like a listing posted for my latest podcast episode with an outline of the podcast. https://rabr.kailejohansen.us to get an idea
1
0
1
Rebel Alliance Briefing Room @rebelalliancebriefingroom.kailejohansen.us
that is understandable, since I did use the word blog... I was just using it because it was part of the context of the post. I would want something that is generic, so I don't have to modify the main code every post, but I have each post get unique comments
0
0
1
Rebel Alliance Briefing Room @rebelalliancebriefingroom.kailejohansen.us
This is awesome stuff. so I just need to change the URI and my blog/webpage will pull the comments directly from bsky? " const response = agent.getPostThread({ uri }); " " I don't use BskyAgent in favour of using fetch directly... "
1
0
3
Graysky ☁️ @graysky.app
yeah, the URI is the identifier of the post that you want to display. I have another tutorial which goes into a lot more detail about how to do this. graysky.app/blog/2023-10...
1
0
3
Rebel Alliance Briefing Room @rebelalliancebriefingroom.kailejohansen.us
I will have to deep dive into this later, I skimmed it over. without a "client" how do I make this work for a blog/web post? I wonder if there could be an option when drafting a post that I click to paste a url that points to said blog post and with a bit of code on the blog it starts happening?
2
1
1
Rebel Alliance Briefing Room @rebelalliancebriefingroom.kailejohansen.us
hey @tokimeki.blue can we get this feature? option to capture comments for blog post. I embed my bsky post on web. use this feature to add comments to blog when the bsky post is replied to? not sure.. how would we get the did from bsky to blog? it would have to be entered manually?
2
0
0
someone @someone814.bsky.social
Not sure if this is what you want, but maybe it helps: bluesky.lol
1
0
1
Rebel Alliance Briefing Room @rebelalliancebriefingroom.kailejohansen.us
Yes and no. Thank you for the kind thoughts. I want to make a post to blue sky that also is embedded on my website. Then use resolvers idea to port the replys to the bottom of that post. I also what the ability to embed my most recent profile posts to a box on my web page. I ask kindly
0
0
0
The Doctor @lucidillusions.in
I should try this and connect it with the short stories. @r4l.lucidillusions.in
1
0
1
Boris @bmann.ca
Nice work! I wonder if this will show replies from people you’ve muted? Basically, does it inherit the settings of your account, or is this just an unauthenticatwd call?
1
0
1