Skip to content

Commit

Permalink
docs(tag-plugins): add url_for and full_url_for(7.0.0+) (#2022)
Browse files Browse the repository at this point in the history

Co-authored-by: yoshinorin <[email protected]>
Co-authored-by: Uiolee <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2023
1 parent 4db1b72 commit 2dff6c7
Show file tree
Hide file tree
Showing 4 changed files with 296 additions and 0 deletions.
74 changes: 74 additions & 0 deletions source/docs/tag-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,80 @@ _hexo-renderer-marked 3.1.0+ can (optionally) resolves the post's path of an ima
<img src="/2020/01/02/hello/foo.jpg" title="lorem ipsum" alt="dolor">
```

## URL

### url_for (7.0.0+)

Returns a url with the root path prefixed. Output is encoded automatically.

```
{% url_for text path [relative] %}
```

**Examples:**

``` yml
_config.yml
root: /blog/ # example
```
```
{% url_for blog index.html %}
```

``` html
<a href="/blog/index.html">blog</a>
```

Relative link, follows `relative_link` option by default
e.g. post/page path is '/foo/bar/index.html'

``` yml
_config.yml
relative_link: true
```
```
{% url_for blog index.html %}
```

``` html
<a href="../../index.html">blog</a>
```

You could also disable it to output a non-relative link, even when `relative_link` is enabled and vice versa.

```
{% url_for blog index.html false %}
```

``` html
<a href="/index.html">blog</a>
```

### full_url_for (7.0.0+)

Returns a url with the `config.url` prefixed. Output is encoded automatically.

```
{% full_url_for text path %}
```

**Examples:**

``` yml
_config.yml
url: https://example.com/blog # example
```
```
{% full_url_for index /a/path %}
```

``` html
<a href="https://example.com/blog/a/path">index</a>
```

## Raw

If certain content is causing processing issues in your posts, wrap it with the `raw` tag to avoid rendering errors.
Expand Down
74 changes: 74 additions & 0 deletions source/ru/docs/tag-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,80 @@ _hexo-renderer-marked 3.1.0+ can (optionally) resolves the post's path of an ima
<img src="/2020/01/02/hello/foo.jpg" title="lorem ipsum" alt="dolor">
```

## URL

### url_for (7.0.0+)

Returns a url with the root path prefixed. Output is encoded automatically.

```
{% url_for text path [relative] %}
```

**Examples:**

``` yml
_config.yml
root: /blog/ # example
```
```
{% url_for blog index.html %}
```

``` html
<a href="/blog/index.html">blog</a>
```

Relative link, follows `relative_link` option by default
e.g. post/page path is '/foo/bar/index.html'

``` yml
_config.yml
relative_link: true
```
```
{% url_for blog index.html %}
```

``` html
<a href="../../index.html">blog</a>
```

You could also disable it to output a non-relative link, even when `relative_link` is enabled and vice versa.

```
{% url_for blog index.html false %}
```

``` html
<a href="/index.html">blog</a>
```

### full_url_for (7.0.0+)

Returns a url with the `config.url` prefixed. Output is encoded automatically.

```
{% full_url_for text path %}
```

**Examples:**

``` yml
_config.yml
url: https://example.com/blog # example
```
```
{% full_url_for index /a/path %}
```

``` html
<a href="https://example.com/blog/a/path">index</a>
```

## Сырцы

Если определённый контент вызывает ошибки обработки в ваших постах, оберните его тегом `raw`, чтобы избежать ошибок обработки.
Expand Down
74 changes: 74 additions & 0 deletions source/zh-cn/docs/tag-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,80 @@ _hexo-renderer-marked 3.1.0+ 可以(可选)自动解析图片的文章路径
<img src="/2020/01/02/hello/foo.jpg" title="lorem ipsum" alt="dolor">
```

## URL

### url_for (7.0.0+)

返回一个带有根路径前缀的URL。输出将会自动编码。

```
{% url_for text path [relative] %}
```

**示例:**

``` yml
_config.yml
root: /blog/ # example
```
```
{% url_for blog index.html %}
```

``` html
<a href="/blog/index.html">blog</a>
```

是否输出相对链接,默认遵循配置文件中 `relative_link` 的值
例如, post/page 的路径值可能是 `/foo/bar/index.html`

``` yml
_config.yml
relative_link: true
```
```
{% url_for blog index.html %}
```

``` html
<a href="../../index.html">blog</a>
```

即使配置文件中启用了 `relative_link`,你也可以使用 `relative` 参数禁用相对链接输出,反之亦然

```
{% url_for blog index.html false %}
```

``` html
<a href="/index.html">blog</a>
```

### full_url_for (7.0.0+)

返回一个以 `config.url` 为前缀的URL。输出将会自动编码。

```
{% full_url_for text path %}
```

**示例:**

``` yml
_config.yml
url: https://example.com/blog # example
```
```
{% full_url_for index /a/path %}
```

``` html
<a href="https://example.com/blog/a/path">index</a>
```

## Raw

如果您想在文章中插入 Swig 标签,可以尝试使用 Raw 标签,以免发生解析异常。
Expand Down
74 changes: 74 additions & 0 deletions source/zh-tw/docs/tag-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,80 @@ _hexo-renderer-marked 3.1.0+ can (optionally) resolves the post's path of an ima
<img src="/2020/01/02/hello/foo.jpg" title="lorem ipsum" alt="dolor">
```

## URL

### url_for (7.0.0+)

Returns a url with the root path prefixed. Output is encoded automatically.

```
{% url_for text path [relative] %}
```

**Examples:**

``` yml
_config.yml
root: /blog/ # example
```
```
{% url_for blog index.html %}
```

``` html
<a href="/blog/index.html">blog</a>
```

Relative link, follows `relative_link` option by default
e.g. post/page path is '/foo/bar/index.html'

``` yml
_config.yml
relative_link: true
```
```
{% url_for blog index.html %}
```

``` html
<a href="../../index.html">blog</a>
```

You could also disable it to output a non-relative link, even when `relative_link` is enabled and vice versa.

```
{% url_for blog index.html false %}
```

``` html
<a href="/index.html">blog</a>
```

### full_url_for (7.0.0+)

Returns a url with the `config.url` prefixed. Output is encoded automatically.

```
{% full_url_for text path %}
```

**Examples:**

``` yml
_config.yml
url: https://example.com/blog # example
```
```
{% full_url_for index /a/path %}
```

``` html
<a href="https://example.com/blog/a/path">index</a>
```

## Raw

如果您要在文章中插入 Swig 標籤,可以試著使用 Raw 標籤,以免發生解析異常。
Expand Down

0 comments on commit 2dff6c7

Please sign in to comment.