提交 fc29613f 编写于 作者: S Suyan 提交者: ULIVZ

docs: add permalink zh translation (#954)

上级 bde4ac4b
......@@ -15,7 +15,7 @@
- [ ] Build-related changes
- [ ] Other, please describe:
If changing the UI of default theme, please provide the **before/after** screenshot:
If changing the UI of default theme, please provide the **before/after** screenshot:
**Does this PR introduce a breaking change?** (check one)
......
# Permalinks
# 永久链接
## Background
## 背景
Before 1.x.x, vuepress retrieves all markdown files in the documents source directory and defines the page links based on the file hierarchy. e.g. if you have the following file structure:
在 1.x.x 版本之前,VuePress 会检索文档源目录下的所有 markdown 文件并按照文件的层次结构去定义页面链接。
比如你有以下的文件结构:
```
├── package.json
......@@ -13,7 +14,7 @@ Before 1.x.x, vuepress retrieves all markdown files in the documents source dire
└── tags.md
```
Then you will get following available pages:
那么你就会获得以下的可用页面:
```
/source/
......@@ -21,36 +22,28 @@ Then you will get following available pages:
/source/_post/intro-vuepress.html
```
However, for a blog system, we hope that the link of a post can be customized. VuePress started supporting this feature from `1.0.0`. which is known as `permalink`. Then, the actual pages would be:
看起来我们已经发现了 blog 的阴暗面。让我们继续看下去。
```
/source/
/source/tags/
/source/2018/4/1/intro-vuepress.html
```
It seems that we have seen the shadow of the blog. Let's continue to look down.
## 永久链接
## Permalinks
一个永久链接是一个旨在未来很多年里维持不变的 URL,由此产生一个发生链接失效(link rot<sup>[1][1]</sup>)的可能性较小的超链接。VuePress 支持一种灵活的方式去生成固定链接,这种方式允许你使用各种模板变量。
A permalink is a URL that is intended to remain unchanged for many years into the future, yielding a hyperlink that is less susceptible to link rot<sup>[1]</sup>. VuePress supports a flexible way to build permalinks, allowing you to leverage various template variables.
默认的永久链接是`/:regular`
The default permalink is `/:regular`.
### 配置永久链接
### Configure Permalinks
You can configure globally to apply it for all pages:
你可以使用全局配置来向所有页面应用永久链接:
```js
// .vuepress/config.js
module.exports = {
permalink: '/:year/:month/:day/:slug'
}
permalink: "/:year/:month/:day/:slug"
};
```
Alternatively, you can also set permalink on a page only, and it will have a higher priority than the global settings.
另外,你也可以只为单独一个页面去设置永久链接。这种方式比全局配置拥有更高的优先级。
📝 __hello.md__:
📝 **hello.md**:
```markdown
---
......@@ -61,14 +54,17 @@ permalink: /hello-world
Hello!
```
### Template Variables
| Variable | Description |
|---|---|
|:year|Published year of posts (4-digit)|
|:month|Published month of posts (2-digit)|
|:i_month|Published month of posts (Without leading zeros)|
|:day|Published day of posts (2-digit)|
|:i_day|Published day of posts (Without leading zeros)|
|:slug|Slugified file path (Without extension)|
|:regular| Permalink generated by VuePress by default, for implementation see [here](https://github.com/vuejs/vuepress/blob/next/packages/%40vuepress/shared-utils/lib/fileToPath.js) |
### 模板变量
| 变量 | 介绍 |
| --- | --- |
|:year|文章发布的年份 (4数字)|
|:month|文章发布的月份 (2数字)|
|:i_month|文章发布的月份 (前面不带0)|
|:day| 文章发布的日份 (2数字)|
|:i_day|文章发布的日份 (前面不带0)|
|:slug| 蛞蝓化文件路径 (不带扩展名)|
|:regular|VuePress默认的生成永久链接的方式,具体实现看 [这里][2]
[1]:https://en.wikipedia.org/wiki/Link_rot
[2]:https://github.com/vuejs/vuepress/blob/next/packages/%40vuepress/shared-utils/lib/fileToPath.js
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册