Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 29 additions & 28 deletions docs/plugins/features/copyright.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This plugin **is disabled globally by default**, you can:
- Manually enable it by setting `copy: true` in page frontmatter
- Set `global: true` in plugin options to enable it globally, and set `copy: false` in 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 via `copy.triggerLength` in page frontmatter.
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.

Expand All @@ -43,22 +43,22 @@ The plugin will generate copyright information from author, license, and page li

### Disable Copy and Selection

If you want to prevent users copying long content, you can set `maxLength` in plugin options to customize this limit, or via `copy.maxLength` in page frontmatter.
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 `disableCopy` in plugin options or `copy.disableCopy` in 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 `disableSelection` in plugin options or `copy.disableSelection` in page frontmatter. This option has higher priority.
- If you don't want users to copy your entire site or specific page text, you can set `disableCopy` in plugin options or `copy.disableCopy` in 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 `disableSelection` in plugin options or `copy.disableSelection` in page frontmatter. The latter has higher priority.

## Options

### author

- Type: `string`
- Details: Default author Information
- Details: Default author information

### license

- Type: `string`
- Details: Default license Information
- Details: Default license information

### authorGetter

Expand All @@ -75,23 +75,27 @@ If you want to prevent users copying long content, you can set `maxLength` in pl
- Type: `(page: Page) => string | null`
- Details: Copyright getter

### triggerLength
### canonical

- Type: `number`
- Default: `100`
- Details: Min content length triggering copyright append
- Type: `string`
- Details: Canonical deploy location

### maxLength
::: tip Example

- Type: `number`
- Default: `0`
- Details: Max content length which allows to copy, `0` means no limit.
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 `canonical` to `https://myblog.com`
- If you prefer the second one, you should set `canonical` to `https://blog.com/username/`

So copyright message triggered on another site also points to your preferred site.

:::

### global

- Type: `boolean`
- Default: `false`
- Details: Whether enable globally.
- Details: Whether enable globally

### disableCopy

Expand All @@ -105,21 +109,17 @@ If you want to prevent users copying long content, you can set `maxLength` in pl
- Default: `false`
- Details: Disable selection

### canonical

- Type: `string`
- Details: Canonical deploy location.

::: tip 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.
### triggerLength

- If you prefer the first one, you should set `canonical` to `https://myblog.com`
- If you prefer the second one, you should set `canonical` to `https://blog.com/username/`
- Type: `number`
- Default: `100`
- Details: Min content length triggering copyright append

So copyright message triggered on another site also points to your preferred site.
### maxLength

:::
- Type: `number`
- Default: `0`
- Details: Max content length which allows to copy, `0` means no limit

### locales

Expand Down Expand Up @@ -208,6 +208,7 @@ So copyright message triggered on another site also points to your preferred sit
- **Turkish** (tr-TR)
- **Korean** (ko-KR)
- **Finnish** (fi-FI)
- **Hungarian** (hu-HU)
- **Indonesian** (id-ID)
- **Dutch** (nl-NL)

Expand All @@ -225,7 +226,7 @@ So copyright message triggered on another site also points to your preferred sit

- Type: `number`
- Default: `0`
- Details: Max content length which allows to copy, `0` means no limit.
- Details: Max content length which allows to copy, `0` means no limit

### copy.disableCopy

Expand Down
58 changes: 28 additions & 30 deletions docs/zh/plugins/features/copyright.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export default {

### 禁用复制和选择

如果你希望禁止用户复制较长内容,你可以在插件选项中设置 `maxLength` 控制这个临界值,或在页面 frontmatter 单独设置 `copy.maxLength`。
如果你希望禁止用户复制较长内容,你可以在插件选项中设置 `maxLength` 控制这个临界值,或在页面 frontmatter 中设置 `copy.maxLength`。

- 如果你不希望用户复制你的整个站点或特定页面文字,你可以在插件选项中设置 `disableCopy` 或在页面 frontmatter 中设置 `copy.disableCopy` 来禁用复制后者具有更高优先级。
- 如果你不希望用户选择你的整个站点或特定页面文字,你可以在插件选项中设置 `disableSelection` 或在页面 frontmatter 中设置 `copy.disableSelection` 来禁用文字选择。此选项具有更高优先级
- 如果你不希望用户复制你的整个站点或特定页面文字,你可以在插件选项中设置 `disableCopy` 或在页面 frontmatter 中设置 `copy.disableCopy` 来禁用复制后者具有更高优先级。
- 如果你不希望用户选择你的整个站点或特定页面文字,你可以在插件选项中设置 `disableSelection` 或在页面 frontmatter 中设置 `copy.disableSelection` 来禁用文字选择。后者具有更高优先级。

## 选项

Expand All @@ -73,19 +73,23 @@ export default {
### copyrightGetter

- 类型:`(page: Page) => string | null`
- 详情:协议信息获取器
- 详情:版权信息获取器

### triggerLength
### canonical

- 类型:`number`
- 默认值:`100`
- 详情:触发附加版权的最小内容长度
- 类型:`string`
- 详情:首选部署位置

### maxLength
::: tip 例子

- 类型:`number`
- 默认值:`0`
- 详情:允许复制的最大内容长度,`0` 意味着无限制。
如果你在 `https://myblog.com` 和 `https://blog.com/username/` 下部署相同的内容,你可能希望选择一个站点作为首选链接。

- 如果你倾向于使用第一个,你应该将 `canonical` 设置为 `https://myblog.com`
- 如果你倾向于使用第二个,你应该将 `canonical` 设置为 `https://blog.com/username/`

这样,在另一个站点触发的版权信息也会指向你的首选站点。

:::

### global

Expand All @@ -105,23 +109,17 @@ export default {
- 默认值:`false`
- 详情:禁用选择

### canonical

- 类型:`string`
- 详情:

首选部署位置。

::: tip 例子

如果你在 `https://myblog.com` 和 `https://blog.com/username/` 下部署相同的内容,你可能希望选择一个站点作为首选链接。
### triggerLength

- 如果你倾向于使用第一个,你应该将 `canonical` 设置为 `https://myblog.com`
- 如果你倾向于使用第二个,你应该将 `canonical` 设置为 `https://blog.com/username/`
- 类型:`number`
- 默认值:`100`
- 详情:触发附加版权的最小内容长度

这样,在另一个站点触发的版权信息也会指向你的首选站点。
### maxLength

:::
- 类型:`number`
- 默认值:`0`
- 详情:允许复制的最大内容长度,`0` 意味着无限制

### locales

Expand Down Expand Up @@ -204,11 +202,12 @@ export default {
- **波兰语** (pl-PL)
- **法语** (fr-FR)
- **西班牙语** (es-ES)
- **斯洛伐克** (sk-SK)
- **斯洛伐克语** (sk-SK)
- **日语** (ja-JP)
- **土耳其语** (tr-TR)
- **韩语** (ko-KR)
- **芬兰语** (fi-FI)
- **匈牙利语** (hu-HU)
- **印尼语** (id-ID)
- **荷兰语** (nl-NL)

Expand All @@ -220,14 +219,13 @@ export default {

- 类型:`number`
- 默认值:`100`
- 详情: 触发附加版权的最小内容长度
- 详情:触发附加版权的最小内容长度

### copy.maxLength

- 类型:`number`
- 默认值:`0`
- 详情:
允许复制的最大内容长度,`0` 意味着无限制。
- 详情:允许复制的最大内容长度,`0` 意味着无限制

### copy.disableCopy

Expand Down
22 changes: 22 additions & 0 deletions plugins/features/plugin-copyright/src/node/copyrightPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@ export const logger = new Logger(PLUGIN_NAME)

const __dirname = import.meta.dirname || getDirname(import.meta.url)

/**
* Copyright plugin
*
* 版权插件
*
* @param options - Plugin options / 插件选项
*
* @example
* ```ts
* import { copyrightPlugin } from '@vuepress/plugin-copyright'
*
* export default {
* plugins: [
* copyrightPlugin({
* author: 'Your Name',
* license: 'MIT',
* global: true,
* }),
* ],
* }
* ```
*/
export const copyrightPlugin =
(options: CopyrightPluginOptions = {}): PluginFunction =>
(app) => {
Expand Down
38 changes: 32 additions & 6 deletions plugins/features/plugin-copyright/src/node/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import type { DefaultLocaleInfo } from '@vuepress/helper'
import type { CopyrightPluginLocaleData } from '../shared/index.js'

/**
* Default locale info for `@vuepress/plugin-copyright`
* Default locale info for copyright plugin
*
* 版权插件的默认多语言信息
*/
export const copyrightLocaleInfo: DefaultLocaleInfo<CopyrightPluginLocaleData> =
[
Expand Down Expand Up @@ -38,6 +40,30 @@ export const copyrightLocaleInfo: DefaultLocaleInfo<CopyrightPluginLocaleData> =
link: ':link',
},
],
[
['uk', 'uk-UA'],
{
author: 'Авторські права :author',
license: 'Ліцензія :license',
link: ':link',
},
],
[
['vi', 'vi-VN'],
{
author: 'Bản quyền thuộc về :author',
license: 'Cấp phép theo :license',
link: ':link',
},
],
[
['pt-BR'],
{
author: 'Direitos autorais de :author',
license: 'Licenciado sob :license',
link: ':link',
},
],
[
['pl', 'pl-PL'],
{
Expand Down Expand Up @@ -74,7 +100,7 @@ export const copyrightLocaleInfo: DefaultLocaleInfo<CopyrightPluginLocaleData> =
['ja', 'ja-JP'],
{
author: '著作権者 :author',
license: ':licenseプロトコルに基づく',
license: ':license ライセンスに基づく',
link: ':link',
},
],
Expand All @@ -87,10 +113,10 @@ export const copyrightLocaleInfo: DefaultLocaleInfo<CopyrightPluginLocaleData> =
},
],
[
['ko', 'ko-KO'],
['ko', 'ko-KR'],
{
author: '저작권자 :author',
license: ':license 프로토콜에 따라',
license: ':license 라이선스에 따라',
link: ':link',
},
],
Expand All @@ -114,15 +140,15 @@ export const copyrightLocaleInfo: DefaultLocaleInfo<CopyrightPluginLocaleData> =
['hu', 'hu-HU'],
{
author: 'Szerzői jog :author',
license: 'Licensz: :license',
license: 'Licenc: :license',
link: ':link',
},
],
[
['id', 'id-ID'],
{
author: 'Hak cipta oleh :author',
license: 'Dibawah Lisensi :license',
license: 'Di bawah lisensi :license',
link: ':link',
},
],
Expand Down
14 changes: 10 additions & 4 deletions plugins/features/plugin-copyright/src/node/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import type {

export interface CopyrightPluginOptions extends CopyrightPluginSharedOptions {
/**
* Author Getter
* Author getter
*
* 作者获取器
*
* @param page - Page object / 页面对象
*/
authorGetter?: <
ExtraPageData extends Record<string, unknown> = Record<never, never>,
Expand All @@ -26,6 +28,8 @@ export interface CopyrightPluginOptions extends CopyrightPluginSharedOptions {
* License getter
*
* 协议信息获取器
*
* @param page - Page object / 页面对象
*/
licenseGetter?: <
ExtraPageData extends Record<string, unknown> = Record<never, never>,
Expand All @@ -39,9 +43,11 @@ export interface CopyrightPluginOptions extends CopyrightPluginSharedOptions {
) => string | null

/**
* Copyright Getter
* Copyright getter
*
* 版权信息获取器
*
* 协议获取器
* @param page - Page object / 页面对象
*/
copyrightGetter?: <
ExtraPageData extends Record<string, unknown> = Record<never, never>,
Expand All @@ -57,7 +63,7 @@ export interface CopyrightPluginOptions extends CopyrightPluginSharedOptions {
/**
* Locales config for copyright
*
* 复制版权的多语言配置
* 版权插件的多语言配置
*/
locales?: LocaleConfig<CopyrightPluginLocaleData>
}
Loading
Loading