Skip to content

Commit

Permalink
feat(plugin-links-check): add links check plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Feb 21, 2024
1 parent 6927f23 commit 082a953
Show file tree
Hide file tree
Showing 33 changed files with 454 additions and 40 deletions.
4 changes: 2 additions & 2 deletions docs/plugins/active-header-links.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export default {

Selector of _header anchor_.

You don't need to specify this option unless you have changed the `permalinkClass` option of [markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor#readme) via [markdown.anchor](../config.md#markdown-anchor).
You don't need to specify this option unless you have changed the `permalinkClass` option of [markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor#readme) via [markdown.anchor](https://vuejs.press/reference/config.html#markdown-anchor).

- Also see:
- [Guide > Markdown > Syntax Extensions > Header Anchors](../../guide/markdown.md#header-anchors)
- [Guide > Markdown > Syntax Extensions > Header Anchors](https://vuejs.press/guide/markdown.html#header-anchors)

### delay

Expand Down
4 changes: 2 additions & 2 deletions docs/plugins/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Register markdown custom containers in your VuePress site.

This plugin simplifies the use of [markdown-it-container](https://github.com/markdown-it/markdown-it-container), but also retains its original capabilities.

The [Custom Containers](../default-theme/markdown.md#custom-containers) of default theme is powered by this plugin.
The [Custom Containers](../themes/default/markdown.md#custom-containers) of default theme is powered by this plugin.

## Usage

Expand Down Expand Up @@ -85,7 +85,7 @@ export default {
```

- Also see:
- [Guide > I18n](../../guide/i18n.md)
- [Guide > I18n](https://vuejs.press/guide/i18n.html)

### before

Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/docsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,21 +315,21 @@ export default {
```

- Also see:
- [Guide > I18n](../../guide/i18n.md)
- [Guide > I18n](https://vuejs.press/guide/i18n.html)

### indexBase

- Type: `string`

- Default: [base](../config.md#base)
- Default: [base](https://vuejs.press/reference/config.html#base)

- Details:

The base path of the search index.

If you are deploying your site to multiple domains, you don't need to submit all of them to DocSearch and generate search index separately. You could choose one of the domains as the _index domain_, and only submit the _index domain_ to Docsearch for crawling search index. Then, you could reuse the search index across all deployments.

However, if the [base](../config.md#base) of your deployments are different for different domains, you need to set the option to the [base](../config.md#base) of your _index domain_, so that other deployments could reuse the search index correctly.
However, if the [base](https://vuejs.press/reference/config.html#base) of your deployments are different for different domains, you need to set the option to the [base](https://vuejs.press/reference/config.html#base) of your _index domain_, so that other deployments could reuse the search index correctly.

### injectStyles

Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/external-link-icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
```

- Also see:
- [Guide > I18n](../../guide/i18n.md)
- [Guide > I18n](https://vuejs.press/guide/i18n.html)

## Frontmatter

Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

This plugin will collect git information of your pages, including the created and updated time, the contributors, etc.

The [lastUpdated](../default-theme/config.md#lastupdated) and [contributors](../default-theme/config.md#contributors) of default theme is powered by this plugin.
The [lastUpdated](../themes/default/config.md#lastupdated) and [contributors](../themes/default/config.md#contributors) of default theme is powered by this plugin.

This plugin is mainly used to develop themes. You won't need to use it directly in most cases.

Expand Down
76 changes: 76 additions & 0 deletions docs/plugins/links-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# links-check

<NpmBadge package="@vuepress/plugin-links-check" />

This plugin will check dead links in your markdown files.

This plugin has been integrated into the default theme.

## Usage

```bash
npm i -D @vuepress/plugin-links-check@next
```

```ts
import { linksCheckPlugin } from '@vuepress/plugin-links-check'

export default {
plugins: [
linksCheckPlugin({
// options
}),
],
}
```

## Options

### dev

- Type: `boolean`

- Default: `true`

- Details:

Whether check dead links in markdown in devServer

### build

- Type: `boolean | 'error'`

- Default: `true`

- Details:

Whether check dead links in markdown in build. If set to `'error'`, the build will fail if there are dead links.

### exclude

- Type: `(string | RegExp)[] | ((link: string, isDev: boolean) => boolean)`

- Details:

The links that should be excluded from checking. You can use a list of strings or regular expressions, or a function that returns a boolean.

- Example:

```ts
linksCheckPlugin({
exclude: [
// exclude links by string
'/exclude-link',
// exclude links by regex
/\/exclude-link-regex/,
],

// or exclude links by function
exclude: (link, isDev) => {
if (isDev) {
return link.startsWith('/exclude-link-dev')
}
return link.startsWith('/exclude-link-build')
},
})
```
2 changes: 1 addition & 1 deletion docs/plugins/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default {
```

- Also see:
- [Guide > I18n](../../guide/i18n.md)
- [Guide > I18n](https://vuejs.press/guide/i18n.html)

### hotKeys

Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/theme-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<NpmBadge package="@vuepress/plugin-theme-data" />

Provide client data for your theme, with VuePress [i18n](../../guide/i18n.md) support.
Provide client data for your theme, with VuePress [i18n](https://vuejs.press/guide/i18n.html) support.

This plugin is mainly used to develop themes, and has been integrated into the default theme. You won't need to use it directly in most cases.

Expand Down
2 changes: 1 addition & 1 deletion docs/plugins/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default {

## Differences with Markdown TOC Syntax

Similar to the [Table of Contents Markdown Syntax](../../guide/markdown.md#table-of-contents), the TOC component that provided by this plugin could be used in your markdown content directly:
Similar to the [Table of Contents Markdown Syntax](https://vuejs.press/guide/markdown.html#table-of-contents), the TOC component that provided by this plugin could be used in your markdown content directly:

```md
<!-- markdown toc syntax -->
Expand Down
36 changes: 28 additions & 8 deletions docs/themes/default/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ export default {
- Also see:
- [Default Theme > Markdown > Custom Containers](./markdown.md#custom-containers)

## themePlugins.externalLinkIcon
## themePlugins.copyCode

- Type: `boolean`
- Type: `CopyCodePluginOptions | boolean`

- Default: `true`

- Details:

Enable [@vuepress/plugin-external-link-icon](../../plugins/external-link-icon.md) or not.
Enable [@vuepress/plugin-copy-code](../../plugins/copy-code.md) or not.

## themePlugins.copyCode
Object value is supported as plugin options.

- Type: `CopyCodePluginOptions | boolean`
## themePlugins.externalLinkIcon

- Type: `boolean`

- Default: `true`

- Details:

Enable [@vuepress/plugin-copy-code](../../plugins/copy-code.md) or not.

Object value is supported as plugin options.
Enable [@vuepress/plugin-external-link-icon](../../plugins/external-link-icon.md) or not.

## themePlugins.git

Expand All @@ -90,6 +90,16 @@ export default {

Enable [@vuepress/plugin-git](../../plugins/git.md) or not.

## themePlugins.linksCheck

- Type: `LinksCheckPluginOptions | boolean`

- Default: `true`

- Details:

Enable [@vuepress/plugin-links-check](../../plugins/links-check.md) or not.

## themePlugins.mediumZoom

- Type: `boolean`
Expand All @@ -110,6 +120,16 @@ export default {

Enable [@vuepress/plugin-nprogress](../../plugins/nprogress.md) or not.

## themePlugins.prismjs

- Type: `boolean`

- Default: `true`

- Details:

Enable [@vuepress/plugin-prismjs](../../plugins/prismjs.md) or not.

## themePlugins.seo

- Type: `SeoPluginOptions | boolean`
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/plugins/active-header-links.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export default {

_标题锚点_ 的选择器。

你通常不需要设置该选项,除非你通过 [markdown.anchor](../config.md#markdown-anchor) 修改了 [markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor#readme)`permalinkClass` 选项。
你通常不需要设置该选项,除非你通过 [markdown.anchor](https://vuejs.press/zh/reference/config.html#markdown-anchor) 修改了 [markdown-it-anchor](https://github.com/valeriangalliat/markdown-it-anchor#readme)`permalinkClass` 选项。

- 参考:
- [指南 > Markdown > 语法扩展 > 标题锚点](../../guide/markdown.md#标题锚点)
- [指南 > Markdown > 语法扩展 > 标题锚点](https://vuejs.press/zh/guide/markdown.html#标题锚点)

### delay

Expand Down
4 changes: 2 additions & 2 deletions docs/zh/plugins/container.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

该插件简化了 [markdown-it-container](https://github.com/markdown-it/markdown-it-container) 的使用方法,但同时也保留了其原本的能力。

默认主题的 [自定义容器](../default-theme/markdown.md#自定义容器) 就是由该插件支持的。
默认主题的 [自定义容器](../themes/default/markdown.md#自定义容器) 就是由该插件支持的。

## 使用方法

Expand Down Expand Up @@ -85,7 +85,7 @@ export default {
```

- 参考:
- [指南 > 多语言支持](../../guide/i18n.md)
- [指南 > 多语言支持](https://vuejs.press/zh/guide/i18n.html)

### before

Expand Down
6 changes: 3 additions & 3 deletions docs/zh/plugins/docsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,21 +314,21 @@ export default {
```

- 参考:
- [指南 > 多语言支持](../../guide/i18n.md)
- [指南 > 多语言支持](https://vuejs.press/zh/guide/i18n.html)

### indexBase

- 类型: `string`

- 默认值: [base](../config.md#base)
- 默认值: [base](https://vuejs.press/zh/reference/config.html#base)

- 详情:

搜索索引基础路径。

如果你需要把你的站点部署到不同的域名上,你不需要把它们全都提交到 Docsearch 上来分别生成搜索索引。你可以选择其中一个域名作为 _索引域名_ ,并且仅将 _索引域名_ 提交到 DocSearch 上来爬去搜索索引。然后,你就可以在不同的部署域名下复用索引。

如果你不同部署域名下的 [base](../config.md#base) 是不一样的,你就需要将这个配置设置成 _索引域名_[base](../config.md#base) ,这样其他的部署域名就可以正确复用索引了。
如果你不同部署域名下的 [base](https://vuejs.press/zh/reference/config.html#base) 是不一样的,你就需要将这个配置设置成 _索引域名_[base](https://vuejs.press/zh/reference/config.html#base) ,这样其他的部署域名就可以正确复用索引了。

### injectStyles

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/plugins/external-link-icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default {
```

- 参考:
- [指南 > 多语言支持](../../guide/i18n.md)
- [指南 > 多语言支持](https://vuejs.press/zh/guide/i18n.html)

## Frontmatter

Expand Down
2 changes: 1 addition & 1 deletion docs/zh/plugins/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

该插件会收集你的页面的 Git 信息,包括创建和更新时间、贡献者等。

默认主题的 [lastUpdated](../default-theme/config.md#lastupdated)[contributors](../default-theme/config.md#contributors) 就是由该插件支持的。
默认主题的 [lastUpdated](../themes/default/config.md#lastupdated)[contributors](../themes/default/config.md#contributors) 就是由该插件支持的。

该插件主要用于开发主题,大部分情况下你不需要直接使用它。

Expand Down
76 changes: 76 additions & 0 deletions docs/zh/plugins/links-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# links-check

<NpmBadge package="@vuepress/plugin-links-check" />

此插件将检查您的 markdown 文件中的死链接。

此插件已集成到默认主题中。

## 使用

```bash
npm i -D @vuepress/plugin-links-check@next
```

```ts
import { linksCheckPlugin } from '@vuepress/plugin-links-check'

export default {
plugins: [
linksCheckPlugin({
// 选项
}),
],
}
```

## 选项

### dev

- 类型:`boolean`

- 默认值:`true`

- 详情:

是否在开发服务器中检查 markdown 中的死链接

### build

- 类型:`boolean | 'error'`

- 默认值:`true`

- 详情:

是否在构建中检查 markdown 中的死链接。如果设置为 `'error'`,则构建将在存在死链接时失败。

### exclude

- 类型:`(string | RegExp)[] | ((link: string, isDev: boolean) => boolean)`

- 详情:

应该从检查中排除的链接。您可以使用字符串或正则表达式的列表,或者返回布尔值的函数。

- 示例:

```ts
linksCheckPlugin({
exclude: [
// 通过字符串排除链接
'/exclude-link',
// 通过正则表达式排除链接
/\/exclude-link-regex/,
],

// 或者通过函数排除链接
exclude: (link, isDev) => {
if (isDev) {
return link.startsWith('/exclude-link-dev')
}
return link.startsWith('/exclude-link-build')
},
})
```
Loading

0 comments on commit 082a953

Please sign in to comment.