https://github.com/studiole/readgithub
A jQuery plugin to load files from GitHub
https://github.com/studiole/readgithub
Last synced: about 1 year ago
JSON representation
A jQuery plugin to load files from GitHub
- Host: GitHub
- URL: https://github.com/studiole/readgithub
- Owner: StudioLE
- License: mit
- Created: 2015-01-17T01:20:49.000Z (over 11 years ago)
- Default Branch: main
- Last Pushed: 2023-04-16T01:31:37.000Z (about 3 years ago)
- Last Synced: 2025-04-04T11:04:26.654Z (about 1 year ago)
- Language: JavaScript
- Size: 174 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# readGitHub.js
A jQuery plugin to load GitHub files into your page
## Install
Packages are available via Bower and NPM
```
npm install --save readgithub
```
```
bower install --save readgithub
```
## Use
Include `dist/css/readgithub.css` and `dist/js/readgithub.js` in your page, ensuring jQuery is loaded first.
``` html
```
Add the following line whereever you would like to render a file from GitHub:
``` html
```
Finally, call the readGitHub method in your javascript
``` js
$(document).ready(function() {
$('[rel~="github"]').readGitHub()
})
```
readGitHub will look for the `rel="github"` and read the requested repository from `data-repo`.
## Configuration
A number of configuration options are available. One of the most powerful features is the option to use a renderer. For instance you can declare a Markdown render, read your `README.md` and readGitHub will load and convert your `.md` as html.
### Using a renderer
``` js
$('[rel~="github"]').readGitHub({
renderer: function(file) {
// Your render function
return file
}
})
```
For instance to render with markdown-it include the script before `readGitHub.js`.
``` html
```
And use the following within your javascript
``` js
$('[rel~="github"]').readGitHub({
renderer: function(file) {
return window.markdownit().render(file)
}
})
```