https://github.com/jperasmus/docsify-copy-code
A docsify plugin that copies Markdown code block to your clipboard
https://github.com/jperasmus/docsify-copy-code
Last synced: 8 months ago
JSON representation
A docsify plugin that copies Markdown code block to your clipboard
- Host: GitHub
- URL: https://github.com/jperasmus/docsify-copy-code
- Owner: jperasmus
- License: mit
- Created: 2017-09-27T19:31:36.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-03-17T07:18:10.000Z (over 1 year ago)
- Last Synced: 2024-04-14T13:51:27.899Z (over 1 year ago)
- Language: JavaScript
- Size: 655 KB
- Stars: 96
- Watchers: 3
- Forks: 75
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-docsify - docsify-copy-code - A docsify plugin that copies Markdown code block to your clipboard [@jperasmus](https://github.com/jperasmus). (Plugins)
README
# docsify-copy-code
[](https://www.npmjs.com/package/docsify-copy-code)
[](https://github.com/jhildenbiddle/docsify-copy-code/blob/master/LICENSE)
A [docsify](https://docsify.js.org) plugin that adds a button to easily copy code blocks to your clipboard.
## Installation
### Production
Add following script tag to your `index.html` after docsify. Specifying the `@[version]` in the URL ensures that the release of a major update (v3.x) will not break your production site:
```html
```
### Development
If you prefer to load the latest version of the library, you may do so by omitting the `@[version]` from the above URL.
```html
```
## Usage
Create a markdown code block with help of triple backticks at the beginning and end of your code. This block will have a copy button on the top right when hovering over it.
## Options
### Button text
Button text can be customized as follows:
```javascript
window.$docsify = {
// docsify-copy-code (defaults)
copyCode: {
buttonText: 'Copy to clipboard',
errorText: 'Error',
successText: 'Copied',
},
};
```
### Localization (l10n)
Button text can also be customized based on the current URL. Object key/value pairs are processed in the order provided.
```javascript
window.$docsify = {
copyCode: {
buttonText: {
'/zh-cn/': '点击复制',
'/ru/': 'Скопировать в буфер обмена',
'/de-de/': 'Klicken Sie zum Kopieren',
'/es/': 'Haga clic para copiar',
'/': 'Copy to clipboard',
},
errorText: {
'/zh-cn/': '错误',
'/ru/': 'ошибка',
'/': 'Error',
},
successText: {
'/zh-cn/': '复制',
'/ru/': 'Скопировано',
'/de-de/': 'Kopiert',
'/es/': 'Copiado',
'/': 'Copied',
},
},
};
```
**Note:** Docsify's [alias](https://docsify.js.org/#/configuration?id=alias) option makes it easy to manage local content using separate directories. See the [`/demo/`](https://github.com/jperasmus/docsify-copy-code/tree/master/demo) content in this repo for an example.
## License
This project is licensed under the MIT License. See the [LICENSE](https://github.com/jperasmus/docsify-copy-code/blob/master/LICENSE) for details.