React components to render GitHub gists and GitLab snippets.
npm install react-gistlab

!npm bundle size (minified + gzip)

The library is created for using Github gists and Gitlab snippets in your React application.
Installation can be done with npm
``sh`
npm install --save react-gistlab
or yarn
`sh`
yarn add react-gistlab
`jsx
import * as React from "react";
import { GithubGist } from "react-gistlab";
import s from "./CodeSnippet.scss";
const CodeSnippet = () => (
LOADING!
}$3
$3
Be careful in using it in production!
Gitlab uses
document.write in their snippets, that's why the snippet not working directly in SPAs. Fetching their snippet directly is blocked by CORS. That's why you should use a disable cors proxy for fetching the snippet. By default it's cors.io. In order to be safe from XSS, you will need to have your own proxy!`jsx
import * as React from "react";import { GitlabSnippet } from "react-gistlab";
import s from "./CodeSnippet.scss";
const CodeSnippet = () => (
url="https://gitlab.com/snippets/1839780"
Loading={() => LOADING!
}
corsProxyURL="https://your.own.proxy/?"
/>
);
`Plans
- [x] Add tests
- [x] Set up CI/CD
Contributions
Contributors are welcome. Please discuss new features and submit PRs for bug fixes with tests.
Run
npm run build` which detects type errors, tests passing status and build the lib if everything is well.