UNPKG

react-utterances-github-comments

Version:

A lightweight React wrapper for Utterances GitHub comment system

100 lines (72 loc) โ€ข 2.34 kB
# 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)