You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simple and flexible component that allows you to embed [GitHub Gists](https://gist.github.com/) in [React](https://reactjs.org/) projects.
3
3
4
-
5
4
## Features
6
5
- Embed a **single file** from Gist repository!
7
6
- Embed **multiple files** from multiple Gist repositories!
8
7
- Embed the **whole Gist** repository!
9
8
-**Easy usage**: Just copy-paste the Gist's repository URL to embed the whole repository, or copy-paste the permalink of an individual file to include just that.
9
+
- Maximize Development Experience with **custom error handling**.
10
10
-**Lightweight**: ~9KB minified (~4kb if gzipped).
11
11
- Packaged as **UMD module** that can be loaded everywhere.
12
12
-**Works both on secret and public repositories**.
13
13
14
14
## Table of contents
15
-
-[Quick Start](#quick-start)
16
-
-[Usage](#usage)
15
+
-[Installation](#installation)
16
+
-[Component Properties](#component-properties)
17
17
-[Examples](#examples)
18
18
-[Browser Support](#browser-support)
19
19
-[Bugs and feature requests](#bugs-and-feature-requests)
20
20
-[Contributing](#contributing)
21
-
-[Creator](#creator)
22
-
-[Licence](#license)
21
+
-[License](#license)
23
22
24
-
## Quick Start
25
-
- Clone the repo: `git clone https://github.com/georgegkas/super-react-gist.git`
26
-
- Install with [npm](https://www.npmjs.com/): `npm install --save super-react-gist`
23
+
## Installation
24
+
### Through NPM
25
+
To install through npm run:
27
26
28
-
## Usage
29
-
**`<Gist url={string} file={string} />`**
30
-
-`url`*{ string }***required** The URL of the Gist repository or the permalink of an individual gist file.
31
-
-`file`*{ string }* Name of a specific file to include.
27
+
```bash
28
+
npm i super-react-gist
29
+
```
30
+
### As UMD module
31
+
**super-react-gist** comes as UMD module. This means you are able to use **super-react-gist** component in your browser!
32
32
33
+
To get started add the following script tag in your html file:
ErrorComponent={() =><div>Could not fetch component</div>}
155
+
/>
156
+
</div>
157
+
)
158
+
```
159
+
160
+
### Listen to error and loading events
161
+
Apart from providing a custom error or loading component, we can also register the corresponding callbacks. The `onLoad` callback is executed when the Gist is fetched successfully, while `onError` callback is executed if could not retrieve the requested Gist.
162
+
163
+
```javascript
164
+
importReactfrom'react'
165
+
importGistfrom'super-react-gist'
166
+
167
+
constMyComponent= () => (
168
+
<div>
169
+
<p>provide the Gist URL without include any file.</p>
Then you are able to access **super-react-gist** component using the `Gist` name, which is the global variable the UMD build has exported. [See this Pen for a demonstration](https://codepen.io/georgegkas/pen/zpzMzz).
191
+
Then you are able to access the `Gist` component using the `Gist` global variable. [See this Pen for a demonstration](https://codepen.io/georgegkas/pen/zpzMzz).
146
192
147
193
## Bugs and feature requests
148
194
Have a bug or a feature request? [Please open a new issue](https://github.com/georgegkas/super-react-gist/issues).
@@ -152,11 +198,5 @@ Please read through our contributing guidelines in [CONTRIBUTING.md](https://git
152
198
153
199
Editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at [http://editorconfig.org](http://editorconfig.org).
Code released under the [MIT License](https://opensource.org/licenses/MIT). See [LICENSE.md](https://github.com/georgegkas/super-react-gist/blob/master/LICENSE.md) for more details.
201
+
## License
202
+
Code released under the [MIT License](https://opensource.org/licenses/MIT). See [LICENSE.md](https://github.com/georgegkas/super-react-gist/blob/master/LICENSE.md) for more details.
<p>Works both on <strong>public</strong> and <strong>secret</strong> gists.</p>
20
20
<p>Oh snap! *face-palm*! In case you didn't notice we can only use the above method to render files that do not contain any uppercase letter. For instance, if our Gist repo contains a file <code>CaMelCase.js</code>, then providing just the permalink will not work!</p>
21
21
<p><strong>Q</strong>: How can we render this <code>CaMelCase.js</code> file?</p>
22
22
<p><strong>A</strong>: By providing a <code>file</code> prop to our <code>Gist</code> component to indicate which file we want to include.</p>
0 commit comments