Giscus is an open-source blog comment service, powered by GitHub Discussions. It’s very similar to Disqus but they don’t use trackers :)
It took me 10-15 minutes to get it up and running on my blog.
Installation
- Follow the steps here: https://giscus.app
- Once you have installed the GitHub App fine-tune the config;
- At the end, you should have some code with some
data-xxx
attributes. - Create a
Comments.atro
component and copy-paste the code in it:
5. Call the component in your blog post container:
- Enjoy 🥳
Dark Mode
If you have a dark mode button, you have to write some JS to update the theme according to the current mode.
I use Tailwind’s dark mode class strategy. Meaning, that when I switch the dark mode “ON”, my HTML
page has a dark CSS class (<html class="dark">
).
The trick here is to listen to observe the document CSS classes and trigger a updateGiscusTheme()
method to update the theme.
My code looks like the following:
Custom styles
Let’s say you want to extend the dark style.
If you want to extend a style, copy/paste the desired styles from
the repository to
public/giscus/dark.css
. Then you can update the data-theme
attribute and put the URL pointing to
your CSS file (i.e. data-theme={${Astro.url.origin}/giscus/dark.css}
).
Notes: If you have a dark mode toggle, you can do something like this:
About the author
Hey, I'm Maxence Poutord, a passionate software engineer. In my day-to-day job, I'm working as a senior front-end engineer at Orderfox. When I'm not working, you can find me travelling the world or cooking.
Follow @_maxpouRecommended posts
1. Split your application into completely isolated modules. 2. Consider micro-frontends architecture. 3. Don't put everything in the Vuex Store
How Testing Library helps you to write better integration test