https://github.com/christopherpickering/eleventy-plugin-edit-on-github
Eleventy plugin to add an "Edit on Github" link to pages.
https://github.com/christopherpickering/eleventy-plugin-edit-on-github
Last synced: 8 months ago
JSON representation
Eleventy plugin to add an "Edit on Github" link to pages.
- Host: GitHub
- URL: https://github.com/christopherpickering/eleventy-plugin-edit-on-github
- Owner: christopherpickering
- License: mit
- Created: 2022-06-21T12:24:30.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2025-02-09T13:57:29.000Z (over 1 year ago)
- Last Synced: 2025-02-09T14:37:52.190Z (over 1 year ago)
- Language: JavaScript
- Size: 2.16 MB
- Stars: 4
- Watchers: 0
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
eleventy-plugin-edit-on-github
An Eleventy shortcode to add an "Edit on Github" link to your pages.
## 🚀 Installation
Install from [npm](https://www.npmjs.com/package/eleventy-plugin-edit-on-github):
```bash
npm i -D eleventy-plugin-edit-on-github
```
## 😎 What does it do?
This is a very useful tool for documentation sites where you'd like your readers to point out updates easily. Add an "Edit on Github" link to your pages that will directly open the github editor for your source files!
## 🏃 Usage
Simply add this shortcode in your templates where you would like the link to appear.
```
{% gh_edit page %}
```
## ⚙️ Configuration
This plugin has one required parameter `github_edit_repo`, which should be the link to your github repository. If files are not at the root, you can also add the `github_edit_path` parameter.
Add to your Eleventy config file:
```js
const editOnGithub = require('eleventy-plugin-edit-on-github');
module.exports = function (eleventyConfig) {
eleventyConfig.addPlugin(editOnGithub, {
// required
github_edit_repo: 'https://github.com/christopherpickering/going-bg',
// optional: defaults
github_edit_path: undefined, // non-root location in git url. root is assumed
github_edit_branch: 'master',
github_edit_text: 'Edit on Github', // html accepted, or javascript function: (page) => { return page.inputPath}
github_edit_class: 'edit-on-github',
github_edit_tag: 'a',
github_edit_attributes: 'target="_blank" rel="noopener"',
github_edit_wrapper: undefined, //ex: "
${edit_on_github}"
});
};
```
Check out the [sample](https://github.com/christopherpickering/eleventy-plugin-edit-on-github/tree/master/sample) site, or clone and run locally with `npm test`.
## 🦘 Out in the Wild
- [djLint docs](https://djlint.com) > With i18n
- [Atlas BI Library docs](https://www.atlas.bi/docs/bi-library/)