Skip to content

Commit fc29613

Browse files
suyanhanxulivz
authored andcommitted
docs: add permalink zh translation (#954)
1 parent bde4ac4 commit fc29613

File tree

2 files changed

+30
-34
lines changed

2 files changed

+30
-34
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- [ ] Build-related changes
1616
- [ ] Other, please describe:
1717

18-
If changing the UI of default theme, please provide the **before/after** screenshot:
18+
If changing the UI of default theme, please provide the **before/after** screenshot:
1919

2020
**Does this PR introduce a breaking change?** (check one)
2121

+29-33
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# Permalinks
1+
# 永久链接
22

3-
## Background
3+
## 背景
44

5-
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:
5+
在 1.x.x 版本之前,VuePress 会检索文档源目录下的所有 markdown 文件并按照文件的层次结构去定义页面链接。
6+
比如你有以下的文件结构:
67

78
```
89
├── package.json
@@ -13,44 +14,36 @@ Before 1.x.x, vuepress retrieves all markdown files in the documents source dire
1314
└── tags.md
1415
```
1516

16-
Then you will get following available pages:
17+
那么你就会获得以下的可用页面:
1718

1819
```
1920
/source/
2021
/source/tags.html
2122
/source/_post/intro-vuepress.html
2223
```
2324

24-
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:
25+
看起来我们已经发现了 blog 的阴暗面。让我们继续看下去。
2526

26-
```
27-
/source/
28-
/source/tags/
29-
/source/2018/4/1/intro-vuepress.html
30-
```
31-
32-
It seems that we have seen the shadow of the blog. Let's continue to look down.
27+
## 永久链接
3328

34-
## Permalinks
29+
一个永久链接是一个旨在未来很多年里维持不变的 URL,由此产生一个发生链接失效(link rot<sup>[1][1]</sup>)的可能性较小的超链接。VuePress 支持一种灵活的方式去生成固定链接,这种方式允许你使用各种模板变量。
3530

36-
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.
31+
默认的永久链接是`/:regular`
3732

38-
The default permalink is `/:regular`.
33+
### 配置永久链接
3934

40-
### Configure Permalinks
41-
42-
You can configure globally to apply it for all pages:
35+
你可以使用全局配置来向所有页面应用永久链接:
4336

4437
```js
4538
// .vuepress/config.js
4639
module.exports = {
47-
permalink: '/:year/:month/:day/:slug'
48-
}
40+
permalink: "/:year/:month/:day/:slug"
41+
};
4942
```
5043

51-
Alternatively, you can also set permalink on a page only, and it will have a higher priority than the global settings.
44+
另外,你也可以只为单独一个页面去设置永久链接。这种方式比全局配置拥有更高的优先级。
5245

53-
📝 __hello.md__:
46+
📝 **hello.md**:
5447

5548
```markdown
5649
---
@@ -61,14 +54,17 @@ permalink: /hello-world
6154
Hello!
6255
```
6356

64-
### Template Variables
65-
66-
| Variable | Description |
67-
|---|---|
68-
|:year|Published year of posts (4-digit)|
69-
|:month|Published month of posts (2-digit)|
70-
|:i_month|Published month of posts (Without leading zeros)|
71-
|:day|Published day of posts (2-digit)|
72-
|:i_day|Published day of posts (Without leading zeros)|
73-
|:slug|Slugified file path (Without extension)|
74-
|: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) |
57+
### 模板变量
58+
59+
| 变量 | 介绍 |
60+
| --- | --- |
61+
|:year|文章发布的年份 (4数字)|
62+
|:month|文章发布的月份 (2数字)|
63+
|:i_month|文章发布的月份 (前面不带0)|
64+
|:day| 文章发布的日份 (2数字)|
65+
|:i_day|文章发布的日份 (前面不带0)|
66+
|:slug| 蛞蝓化文件路径 (不带扩展名)|
67+
|:regular|VuePress默认的生成永久链接的方式,具体实现看 [这里][2]
68+
69+
[1]:https://en.wikipedia.org/wiki/Link_rot
70+
[2]:https://github.com/vuejs/vuepress/blob/next/packages/%40vuepress/shared-utils/lib/fileToPath.js

0 commit comments

Comments
 (0)