vuepress-plugin-copyright
is a VuePress plugin that handles copy behaviors.
npm install -g vuepress-plugin-copyright
# OR
yarn global add vuepress-plugin-copyright
npm install vuepress-plugin-copyright
# OR
yarn add vuepress-plugin-copyright
module.exports = {
plugins: [
['copyright', {
noCopy: true, // the selected text will be uncopiable
minLength: 100, // if its length is greater than 100
}],
]
}
or
module.exports = {
plugins: {
copyright: {
// disable the plugin by default
// you can activate the plugin in frontmatter
disabled: true,
// texts will be unselectable
noSelect: true,
},
}
}
You can enable or disable this plugin for the current page in frontmatter:
---
copyright: false # disable the plugin in this page
---
You can also do some local configuration:
---
copyright:
minLength: 40 # It will override global configuration.
---
You can customize your clipboard with clipboardComponent
. Here is a simple example:
<template>
<div>
<p>
Copyright © VuePress Community
Link: <a :href="location">{{ location }}</a>
</p>
<div v-html="html"/>
</div>
</template>
<script>
export default {
props: ['html'],
created () {
this.location = window.location
},
}
</script>
Options marked with are also allowed in frontmatter. Options marked with only take effect when the default clipboard component is used.
- type:
boolean
- default:
false
Whether to disable this plugin by default.
- type:
boolean
- default:
false
Whether to prohibit copying.
- type:
boolean
- default:
false
Whether to prohibit selecting.
- type:
number
- default:
0
The minimum text length that triggers the clipboard component or the noCopy
effect.
- type:
string | Record<string, string>
- default:
'Author'
Author name. You can provide a string or an i18n object, for example:
{
"en-US": "Author",
"zh-CN": "作者"
}
- type:
string
- default:
undefined
The path to the custom clipboard component. If a relative path is specified, it will be resolved based on sourceDir
.