-
-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: slugify filter from Jekyll, #443
- Loading branch information
Showing
8 changed files
with
215 additions
and
4 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
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,61 @@ | ||
--- | ||
title: slugify | ||
--- | ||
|
||
{% since %}v10.13.0{% endsince %} | ||
|
||
Convert a string into a lowercase URL "slug". The slugify filter accepts 2 options: | ||
|
||
1. `mode: string`. The default is `"default"`. They are as follows (with what they filter): | ||
- `"none"`: no characters | ||
- `"raw"`: spaces | ||
- `"default"`: spaces and non-alphanumeric characters | ||
- `"pretty"`: spaces and non-alphanumeric characters except for `._~!$&'()+,;=@` | ||
- `"ascii"`: spaces, non-alphanumeric, and non-ASCII characters | ||
- `"latin"`: like default, except Latin characters are first transliterated (e.g. àèïòü to aeiou). | ||
2. `case: boolean`. The default is `false`. The original case of slug will be retained if set to `true`. | ||
|
||
Input | ||
```liquid | ||
{{ "The _config.yml file" | slugify }} | ||
``` | ||
Output | ||
``` | ||
the-config-yml-file | ||
``` | ||
|
||
Input | ||
```liquid | ||
{{ "The _config.yml file" | slugify: "pretty" }} | ||
``` | ||
Output | ||
``` | ||
the-_config.yml-file | ||
``` | ||
|
||
Input | ||
```liquid | ||
{{ "The _cönfig.yml file" | slugify: "ascii" }} | ||
``` | ||
Output | ||
``` | ||
the-c-nfig-yml-file | ||
``` | ||
|
||
Input | ||
```liquid | ||
{{ "The cönfig.yml file" | slugify: "latin" }} | ||
``` | ||
Output | ||
``` | ||
the-config-yml-file | ||
``` | ||
|
||
Input | ||
```liquid | ||
{{ "The cönfig.yml file" | slugify: "latin", true }} | ||
``` | ||
Output | ||
``` | ||
The-config-yml-file | ||
``` |
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,59 @@ | ||
--- | ||
title: slugify | ||
--- | ||
|
||
将字符串转换为小写的 URL “slug”。`slugify` 过滤器接受两个选项: | ||
|
||
1. `mode: string`。默认为`"default"`,它可选的值如下: | ||
- `"none"`:没有字符 | ||
- `"raw"`:空格 | ||
- `"default"`:空格和非字母数字字符 | ||
- `"pretty"`:空格和非字母数字字符,但排除 `._~!$&'()+,;=@` | ||
- `"ascii"`:空格、非字母数字和非 ASCII 字符 | ||
- `"latin"`:与默认相同,但拉丁字符首先进行音译(例如,àèïòü 转换为 aeiou)。 | ||
2. `case: boolean`。默认为 `false`。如果为 `true`,则保留 `slug` 原本的大小写。 | ||
|
||
输入 | ||
```liquid | ||
{{ "The _config.yml file" | slugify }} | ||
``` | ||
输出 | ||
``` | ||
the-config-yml-file | ||
``` | ||
|
||
输入 | ||
```liquid | ||
{{ "The _config.yml file" | slugify: "pretty" }} | ||
``` | ||
输出 | ||
``` | ||
the-_config.yml-file | ||
``` | ||
|
||
输入 | ||
```liquid | ||
{{ "The _cönfig.yml file" | slugify: "ascii" }} | ||
``` | ||
输出 | ||
``` | ||
the-c-nfig-yml-file | ||
``` | ||
|
||
输入 | ||
```liquid | ||
{{ "The cönfig.yml file" | slugify: "latin" }} | ||
``` | ||
输出 | ||
``` | ||
the-config-yml-file | ||
``` | ||
|
||
输入 | ||
```liquid | ||
{{ "The cönfig.yml file" | slugify: "latin", true }} | ||
``` | ||
输出 | ||
``` | ||
The-config-yml-file | ||
``` |
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
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