English
copyright
This plugin can automatically append copyright information when visitors copy content from your site, and can also prohibit site copying or selection.
Usage
npm i -D @vuepress/plugin-copyright@nextimport { copyrightPlugin } from '@vuepress/plugin-copyright'
export default {
plugins: [
copyrightPlugin({
// options
}),
],
}Guide
Enabling Copyright
This plugin is disabled globally by default, you can:
- Manually enable it by setting
copy: truein page frontmatter - Set
global: truein plugin options to enable it globally, and setcopy: falsein page frontmatter to disable it.
To avoid disturbing visitors, copyright information will be appended only when the copied content length is greater than 100. Set triggerLength in plugin options if you want to change this threshold, or set copy.triggerLength in page frontmatter.
You can set default author and license information via author and license in plugin options.
If your site have different authors and license in different pages, you can set authorGetter and licenseGetter with function (page: Page) => string that takes the current page object as parameter and returns the corresponding information.
The plugin will generate copyright information from author, license, and page link via template by default, and append it when copying. If you think that this is not flexible enough, you can set copyrightGetter option to return a completely customized information with Page object or return null to use the default template.
Disabling Copy and Selection
If you want to prevent users copying long content, you can set maxLength in plugin options to customize this limit, or set copy.maxLength in page frontmatter.
- If you don't want users to copy your entire site or specific page text, you can set
disableCopyin plugin options orcopy.disableCopyin page frontmatter. The latter has higher priority. - If you don't want users to select your entire site or specific page text, you can set
disableSelectionin plugin options orcopy.disableSelectionin page frontmatter. The latter has higher priority.
Options
author
stringDefault author information.
license
stringDefault license information.
authorGetter
(page: Page) => string | nullAuthor getter. It takes the current page as the parameter and returns the author information.
licenseGetter
(page: Page) => string | nullLicense getter. It takes the current page as the parameter and returns the license information.
copyrightGetter
(page: Page) => string | nullCopyright getter. It takes the current page as the parameter and returns a completely customized copyright information, or null to use the default template.
canonical
stringCanonical hostname with base, which is used as the reference link in the appended copyright information.
Example
If you are deploying same content under https://myblog.com and https://blog.com/username/, you may want to prefer one site as reference link.
- If you prefer the first one, you should set
canonicaltohttps://myblog.com - If you prefer the second one, you should set
canonicaltohttps://blog.com/username/
So copyright message triggered on another site also points to your preferred site.
global
booleanWhether to enable the plugin globally.
See also: Enabling Copyright.
disableCopy
booleanWhether to disable copying.
See also: Disabling Copy and Selection.
disableSelection
booleanWhether to disable selection.
See also: Disabling Copy and Selection.
triggerLength
numberDefault
100Min content length triggering copyright append.
maxLength
numberDefault
0Max content length which allows to copy, 0 means no limit.
locales
CopyrightPluginLocaleConfigLocale config of the plugin.
See also: Locales.
locales.<localePath>.author
stringAuthor text, where :author will be replaced by the author.
locales.<localePath>.license
stringLicense text, where :license will be replaced by the current license.
locales.<localePath>.link
stringLink text, where :link will be replaced by the current page link.
Frontmatter
copy
boolean | objectWhether to enable the plugin for the current page, or an object to configure it.
Set it to true to enable the plugin on the current page, or false to disable it when the plugin is enabled globally.
copy.triggerLength
numberDefault
100Min content length triggering copyright append. This overrides the global triggerLength option.
copy.maxLength
numberDefault
0Max content length which allows to copy, 0 means no limit. This overrides the global maxLength option.
copy.disableCopy
booleanDefault
falseWhether to disable copying. This overrides the global disableCopy option.
copy.disableSelection
booleanDefault
falseWhether to disable selection. This overrides the global disableSelection option.
