vuepress-plugin-copyright

1.0.2 • Public • Published

vuepress-plugin-copyright

npm

vuepress-plugin-copyright is a VuePress plugin that handles copy behaviors.

Usage

Global Installation

npm install -g vuepress-plugin-copyright
# OR 
yarn global add vuepress-plugin-copyright

Local Installation

npm install vuepress-plugin-copyright
# OR 
yarn add vuepress-plugin-copyright

Add to config.js

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,
    },
  }
}

Use Frontmatter

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. 
---

Custom Clipboard

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>

Configurations

Options marked with are also allowed in frontmatter. Options marked with only take effect when the default clipboard component is used.

disabled

  • type: boolean
  • default: false

Whether to disable this plugin by default.

noCopy

  • type: boolean
  • default: false

Whether to prohibit copying.

noSelect

  • type: boolean
  • default: false

Whether to prohibit selecting.

minLength

  • type: number
  • default: 0

The minimum text length that triggers the clipboard component or the noCopy effect.

authorName

  • 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": "作者"
}

clipboardComponent

  • type: string
  • default: undefined

The path to the custom clipboard component. If a relative path is specified, it will be resolved based on sourceDir.

Package Sidebar

Install

npm i vuepress-plugin-copyright

Weekly Downloads

158

Version

1.0.2

License

MIT

Unpacked Size

9.17 kB

Total Files

11

Last publish

Collaborators

  • shigma
  • meteorlxy