Comment System
Giscus comments backed by GitHub Discussions
Giscus Comment System#
Setup#
- Enable Discussions in the public GitHub repository.
- Install the giscus app ↗ on that repository.
- Create a discussion category, for example
Comments. - Open giscus.app ↗, choose the repository and category,
then copy
data-repo-idanddata-category-id. - Fill them into
src/site.config.ts:
src/site.config.ts
export const integ: IntegrationUserConfig = {
// ...
giscus: {
enable: true,
repo: 'owner/repo',
repoId: 'R_...',
category: 'Announcements',
categoryId: 'DIC_...',
mapping: 'pathname',
strict: '0',
reactionsEnabled: '1',
inputPosition: 'bottom',
theme: 'preferred_color_scheme',
lang: 'zh-CN'
}
}tsMapping#
Use mapping: 'pathname'. Each article is identified by its URL pathname, so
the domain can change without losing the discussion mapping.
Usage#
The layouts already render the component:
import Giscus from '@/components/comments/Giscus.astro'
<Giscus />astroIt is enabled per post through the comment: true frontmatter field.