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
stringDefault author information.
stringDefault license information.
(page: Page) => string | nullAuthor getter. It takes the current page as the parameter and returns the author information.
(page: Page) => string | nullLicense getter. It takes the current page as the parameter and returns the license information.
(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.
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.
booleanWhether to enable the plugin globally.
See also: Enabling Copyright.
booleanWhether to disable copying.
See also: Disabling Copy and Selection.
booleanWhether to disable selection.
See also: Disabling Copy and Selection.
number100Min content length triggering copyright append.
number0Max content length which allows to copy, 0 means no limit.
CopyrightPluginLocaleConfigLocale config of the plugin.
See also: Locales.
stringAuthor text, where :author will be replaced by the author.
stringLicense text, where :license will be replaced by the current license.
stringLink text, where :link will be replaced by the current page link.
Frontmatter
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.
number100Min content length triggering copyright append. This overrides the global triggerLength option.
number0Max content length which allows to copy, 0 means no limit. This overrides the global maxLength option.
booleanfalseWhether to disable copying. This overrides the global disableCopy option.
booleanfalseWhether to disable selection. This overrides the global disableSelection option.
