Adding Comments to My Blog with Giscus!

Next.js
React
Giscus
GitHub
Comments
AI

12/3/2024


286 words · 2 min read

Share this post:


Export:

Adding Comments to My Blog with Giscus!

FirstComment

All-in-all, it took under 60 minutes ⏱️ to code, tweak, clean lint errors, and deploy 🚀 Including the time it took to write this blog post. That's the power of modern tooling ✨

After 42 years of coding, I'm still amazed by how modern tools and AI can make development such a joyful experience. Today, I'm thrilled to share how I added comments to my blog using Giscus, with some help from Cursor.AI!

What is Giscus?

Giscus is a comments system powered by GitHub Discussions. It's:

  • Open source and free
  • No ads, always free, and privacy-focused
  • Powered by GitHub Discussions
  • Supports markdown and GitHub-flavored reactions
  • Completely customizable

How We Added It

The implementation was surprisingly straightforward:

  1. First, we installed the Giscus React component:
npm install @giscus/react
  1. Created a new Comments component that wraps Giscus with some nice Joy UI styling:
import { Box } from '@mui/joy';
import { Giscus } from '@giscus/react';

export function Comments() {
  return (
    <Box sx={{ mt: 4 }}>
      <Giscus
        repo="yourusername/repo"
        repoId="your-repo-id"
        category="Announcements"
        categoryId="your-category-id"
        mapping="pathname"
        reactionsEnabled="1"
        emitMetadata="0"
        inputPosition="top"
        theme="preferred_color_scheme"
        lang="en"
      />
    </Box>
  );
}
  1. Added it to our blog post layout, and voilà!

Pro Tip: Giscus automatically handles dark/light mode switching when you set theme to "preferred_color_scheme"!

The Magic of Modern Development

What amazes me most is how seamlessly everything came together:

Next.js for the framework
Joy UI for beautiful components
Giscus for comments
GitHub for hosting discussions

And the best part? You can see it in action right below this post! Feel free to leave a comment and join the discussion.



Subscribe to the Newsletter

Get notified when I publish new blog posts about game development, AI, entrepreneurship, and technology. No spam, unsubscribe anytime.

By subscribing, you agree to receive emails from Erik Bethke. You can unsubscribe at any time.

Comments

Loading comments...

Comments are powered by Giscus. You'll need a GitHub account to comment.