react-utterances-github-comments
Version:
A lightweight React wrapper for Utterances GitHub comment system
100 lines (72 loc) โข 2.34 kB
Markdown
# react-utterances-github-comments
๐ฌ A lightweight React wrapper for [Utterances](https://utteranc.es/), the GitHub-powered comment widget.
## โจ Features
- โ
Lightweight and framework-agnostic (just React)
- ๐ Uses GitHub issues to store comments
- ๐จ Theme support (light, dark, preferred-color-scheme)
- ๐ป Ideal for blogs, documentation, or static sites
## ๐ฆ Installation
```bash
npm install react-utterances-github-comments
```
or
```bash
yarn add react-utterances-github-comments
```
## ๐ Usage
```tsx
import GithubComments from 'react-utterances-github-comments';
function BlogPost() {
return (
<GithubComments
repo="your-username/your-repo"
issueTerm="pathname"
theme="github-light"
label="comentario"
titleText="Deja tu comentario"
loadingText="Cargando comentarios..."
/>
);
}
```
## โ๏ธ Props
| Prop | Type | Required | Description |
|---------------|----------|----------|-------------|
| `repo` | string | โ
| GitHub repo in the format `user/repo` |
| `issueTerm` | string | โ
| How issues are matched: `pathname`, `url`, `title`, etc. |
| `theme` | string | โ | Utterances theme (`github-light`, `github-dark`, etc.) |
| `label` | string | โ | GitHub issue label |
| `titleText` | string | โ | Title shown above the comment box |
| `loadingText` | string | โ | Text shown while Utterances is loading |
| `className` | string | โ | Custom class for the wrapping `<section>` |
## ๐งช Example with dynamic theme switching
```tsx
const [theme, setTheme] = useState('github-light');
return (
<>
<select onChange={(e) => setTheme(e.target.value)}>
<option value="github-light">Light</option>
<option value="github-dark">Dark</option>
<option value="preferred-color-scheme">Auto</option>
</select>
<GithubComments
repo="your-username/your-repo"
issueTerm="pathname"
theme={theme}
/>
</>
);
```
## ๐ License
MIT
## โ๏ธ Author
Made with โค๏ธ by Percy Chuzon
๐ง contacto@percychuzon.com
๐ [GitHub](https://github.com/perch33)