-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
__tests__ | ||
__mocks__ | ||
.temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# @vuepress/plugin-clean-urls | ||
|
||
> clean urls plugin for vuepress | ||
See [documentation](https://vuepress.vuejs.org/plugin/official/plugin-clean-urls.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module.exports = (options = {}, context) => { | ||
const { | ||
normalSuffix = '', | ||
indexSuffix = '/' | ||
} = options | ||
|
||
return { | ||
extendPageData (page) { | ||
const { regularPath, frontmatter = {}} = page | ||
if (frontmatter.permalink) return | ||
if (regularPath.endsWith('.html')) { | ||
// normal path | ||
// e.g. foo/bar.md -> foo/bar.html | ||
page.path = regularPath.slice(0, -5) + normalSuffix | ||
} else if (regularPath.endsWith('/')) { | ||
// index path | ||
// e.g. foo/index.md -> foo/ | ||
page.path = regularPath.slice(0, -1) + indexSuffix | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "@vuepress/plugin-clean-urls", | ||
"version": "1.0.0-alpha.39", | ||
"description": "clean urls plugin for vuepress", | ||
"main": "index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/vuejs/vuepress.git", | ||
"directory": "packages/@vuepress/plugin-clean-urls" | ||
}, | ||
"keywords": [ | ||
"documentation", | ||
"vue", | ||
"vuepress", | ||
"generator" | ||
], | ||
"author": "Shigma <1700011071@pku.edu.cn>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/vuejs/vuepress/issues" | ||
}, | ||
"homepage": "https://github.com/vuejs/vuepress/packages/@vuepress/plugin-clean-urls#readme" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: clean-urls | ||
metaTitle: A plugin of automatically generating clean urls | VuePress | ||
--- | ||
|
||
# [@vuepress/plugin-clean-urls](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/plugin-clean-urls) | ||
|
||
> A plugin of automatically generating clean urls | ||
## Install | ||
|
||
```bash | ||
yarn add -D @vuepress/plugin-clean-urls | ||
# OR npm install -D @vuepress/plugin-clean-urls | ||
``` | ||
|
||
## Usage | ||
|
||
```javascript | ||
module.exports = { | ||
plugins: ['@vuepress/clean-urls'] | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
### normalSuffix | ||
|
||
- Type: `string` | ||
- Default: `''` | ||
|
||
The suffix for normal pages. For example, `foo/bar.md` will become: | ||
|
||
- `foo/bar.html` by default (without this plugin) | ||
- `foo/bar/` (with `normalSuffix` set to `'/'`) | ||
- `foo/bar` (with `normalSuffix` set to `''`) | ||
|
||
### indexSuffix | ||
|
||
- Type: `string` | ||
- Default: `'/'` | ||
|
||
The suffix for index pages. For example, `foo/index.md` will become: | ||
|
||
- `foo/` by default (without this plugin) | ||
- `foo` (with `indexSuffix` set to `''`) | ||
- `foo/index.html` (with `indexSuffix` set to `'/index.html'`) | ||
|
||
::: tip | ||
An index page is a page with a file name of index.md or readme.md (case insensitive). | ||
::: |
51 changes: 51 additions & 0 deletions
51
packages/docs/docs/zh/plugin/official/plugin-clean-urls.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: clean-urls | ||
metaTitle: 自动生成简洁链接的插件 | VuePress | ||
--- | ||
|
||
# [@vuepress/plugin-clean-urls](https://github.com/vuejs/vuepress/tree/master/packages/@vuepress/plugin-clean-urls) | ||
|
||
> 自动生成简洁链接的插件 | ||
## 安装 | ||
|
||
```bash | ||
yarn add -D @vuepress/plugin-clean-urls | ||
# OR npm install -D @vuepress/plugin-clean-urls | ||
``` | ||
|
||
## 使用 | ||
|
||
```javascript | ||
module.exports = { | ||
plugins: ['@vuepress/clean-urls'] | ||
} | ||
``` | ||
|
||
## 选项 | ||
|
||
### normalSuffix | ||
|
||
- 类型: `string` | ||
- 默认值: `''` | ||
|
||
普通页面的链接后缀。举个例子,`foo/bar.md` 会自动变成: | ||
|
||
- `foo/bar.html` 在默认情况下(未安装本插件时) | ||
- `foo/bar/`(当 `normalSuffix` 被设为 `'/'` 时) | ||
- `foo/bar`(当 `normalSuffix` 被设为 `''` 时) | ||
|
||
### indexSuffix | ||
|
||
- 类型: `string` | ||
- 默认值: `'/'` | ||
|
||
索引页面的链接后缀。举个例子,`foo/index.md` 会自动变成: | ||
|
||
- `foo/` 在默认情况下(未安装本插件时) | ||
- `foo`(当 `indexSuffix` 被设为 `''` 时) | ||
- `foo/index.html`(当 `indexSuffix` 被设为 `'/index.html'` 时) | ||
|
||
::: tip | ||
索引页面是指文件名为 index.md 或者 readme.md 的页面(不区分大小写)。 | ||
::: |