Skip to content

Commit 94e5838

Browse files
shigmaulivz
authored andcommitted
docs: update links (#1440)
1 parent 93b2ca1 commit 94e5838

File tree

2 files changed

+28
-34
lines changed

2 files changed

+28
-34
lines changed

packages/docs/docs/guide/markdown.md

+14-17
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,7 @@ Headers automatically get anchor links applied. Rendering of anchors can be conf
88

99
### Internal Links
1010

11-
Inbound links ending in `.md` or `.html` are converted to `<router-link>` for SPA navigation.
12-
13-
Each sub-directory in your static site should contain a `README.md`. It will automatically be converted to `index.html`.
14-
15-
::: tip
16-
When writing the relative path to a directory's `index.html`, don't forget to close it off with a `/`, otherwise you will get a 404. For example, use `/config/` instead of `/config`.
17-
:::
18-
19-
If you want to link to another markdown file within a directory, remember to:
20-
21-
1. Append it with either `.html` or `.md`
22-
2. Make sure the case matches since the path is case-sensitive
23-
24-
#### Example
11+
Internal links are converted to `<router-link>` for SPA navigation. Also, every `README.md` or `index.md` contained in each sub-directory will automatically be converted to `index.html`, with corresponding url `/`.
2512

2613
Given the following directory structure:
2714

@@ -38,14 +25,24 @@ Given the following directory structure:
3825
└─ four.md
3926
```
4027

28+
And providing you are in `foo/one.md`:
29+
4130
```md
4231
[Home](/) <!-- Sends the user to the root README.md -->
4332
[foo](/foo/) <!-- Sends the user to index.html of directory foo -->
44-
[foo heading anchor](/foo/#heading) <!-- Anchors user to a heading in the foo README file -->
45-
[foo - one](/foo/one.html) <!-- You can append .html -->
46-
[foo - two](/foo/two.md) <!-- Or you can append .md -->
33+
[foo heading](./#heading) <!-- Anchors user to a heading in the foo README file -->
34+
[bar - three](../bar/three.md) <!-- You can append .md (recommended) -->
35+
[bar - four](../bar/four.html) <!-- Or you can append .html -->
4736
```
4837

38+
### Redirection for URLs <Badge text="1.0.0-alpha.37"/>
39+
40+
VuePress supports redirecting to clean links. If a link `/foo` is not found, VuePress will look for a existing `/foo/` or `/foo.html`. Conversely, when one of `/foo/` or `/foo.html` is not found, VuePress will also try the other. With this feature, we can customize your website's urls with the official plugin [@vuepress/plugin-clean-urls](../plugin/official/plugin-clean-urls.md).
41+
42+
::: tip
43+
Regardless of whether the permalink and clean-urls plugins are used, your relative path should be defined by the current file structure. In the above example, even though you set the path of `/foo/one.md` to `/foo/one/`, you should still access `/foo/two.md` via `./two.md`.
44+
:::
45+
4946
### External Links
5047

5148
Outbound links automatically gets `target="_blank" rel="noopener noreferrer"`:

packages/docs/docs/zh/guide/markdown.md

+14-17
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,7 @@
88

99
### 内部链接
1010

11-
内部的、并以 `.md` or `.html` 结尾的链接,将会被转换成 `<router-link>` 用于 SPA 导航。
12-
13-
站内的每一个子文件夹都应当有一个 `README.md` 文件,它会被自动编译为 `index.html`
14-
15-
::: tip
16-
在链接到一个文件夹的 `index.html` 时,确保你的链接以 `/` 结尾,否则该链接将导致 404。比如,用 `/config/` 而不是 `/config`
17-
:::
18-
19-
如果你想要链接到另一个 markdown 文件:
20-
21-
1. 确保链接以 `.html``.md` 结尾;
22-
2. 确保路径大小写正确,因为路径的匹配是大小写敏感的。
23-
24-
#### 示例
11+
网站内部的的链接,将会被转换成 `<router-link>` 用于 SPA 导航。同时,站内的每一个文件夹下的 `README.md` 或者 `index.md` 文件都会被自动编译为 `index.html`,对应的链接将被视为 `/`
2512

2613
以如下的文件结构为例:
2714

@@ -38,14 +25,24 @@
3825
└─ four.md
3926
```
4027

28+
假设你现在在 `foo/one.md` 中:
29+
4130
``` md
4231
[Home](/) <!-- 跳转到根部的 README.md -->
4332
[foo](/foo/) <!-- 跳转到 foo 文件夹的 index.html -->
44-
[foo heading anchor](/foo/#heading) <!-- 跳转到 foo/index.html 的特定 anchor 位置 -->
45-
[foo - one](/foo/one.html) <!-- 具体文件可以使用 .html 结尾 -->
46-
[foo - two](/foo/two.md) <!-- 也可以用 .md -->
33+
[foo heading](./#heading) <!-- 跳转到 foo/index.html 的特定标题位置 -->
34+
[bar - three](../bar/three.md) <!-- 具体文件可以使用 .md 结尾(推荐) -->
35+
[bar - four](../bar/four.html) <!-- 也可以用 .html -->
4736
```
4837

38+
### 链接的重定向 <Badge text="1.0.0-alpha.37"/>
39+
40+
VuePress 支持重定向到干净链接。如果一个链接 `/foo` 找不到,VuePress 会自行寻找一个可用的 `/foo/``/foo.html`。反过来,当 `/foo/``/foo.html` 中的一个找不到时,VuePress 也会尝试寻找另一个。借助这种特性,我们可以通过官方插件 [@vuepress/plugin-clean-urls](../plugin/official/plugin-clean-urls.md) 定制你的网站路径。
41+
42+
::: tip 注意
43+
无论是否使用了 permalink 和 clean-urls 插件,你的相对路径都应该依赖于当前的文件结构来定义。在上面的例子中,即使你将 `/foo/one.md` 的路径设为了 `/foo/one/`,你依然应该通过 `./two.md` 来访问 `/foo/two.md`
44+
:::
45+
4946
### 外部链接
5047

5148
外部的链接将会被自动地设置为 `target="_blank" rel="noopener noreferrer"`:

0 commit comments

Comments
 (0)