Skip to content

Commit

Permalink
docs(api/filter): before_post_render & after_post_render process all …
Browse files Browse the repository at this point in the history
…files
  • Loading branch information
curbengh committed Aug 8, 2020
1 parent ff94be0 commit 62e2042
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 14 deletions.
17 changes: 15 additions & 2 deletions source/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,18 @@ Executed before a post is rendered. Refer to [post rendering](posts.html#Render)
For example, to transform the title to lower case:

``` js
hexo.extend.filter.register('before_post_render', function(data){
hexo.extend.filter.register('before_post_render', function(data) {
data.title = data.title.toLowerCase();
return data;
});
```

This filter matches every files in the `source/` folder, it may be necessary to skip non-markdown files, unless those files are listed in [`config.skip_render`](/docs/configuration#Directory); `themes/<your-theme>/source/` folder is not processed by this filter.

``` js
hexo.extend.filter.register('before_post_render', function(data) {
if (data.source.endsWith('.md') === false) return data;

data.title = data.title.toLowerCase();
return data;
});
Expand All @@ -110,12 +121,14 @@ Executed after a post is rendered. Refer to [post rendering](posts.html#Render)
For example, to replace `@username` with a link to a Twitter profile:

``` js
hexo.extend.filter.register('after_post_render', function(data){
hexo.extend.filter.register('after_post_render', function(data) {
data.content = data.content.replace(/@(\d+)/, '<a href="http://twitter.com/$1">#$1</a>');
return data;
});
```

This filter matches every files in the `source/` folder, see [`before_post_render`](#before-post-render) section for more details.

### before_exit

Executed before Hexo is about to exit -- this will run right after `hexo.exit` is called.
Expand Down
17 changes: 15 additions & 2 deletions source/ko/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,18 @@ Post가 생성되기 전에 실행됩니다. 실행 단계에 대해 더 알아
아래 예시는 title을 소문자로 변경하는 것을 보여줍니다.

``` js
hexo.extend.filter.register('before_post_render', function(data){
hexo.extend.filter.register('before_post_render', function(data) {
data.title = data.title.toLowerCase();
return data;
});
```

This filter matches every files in the `source/` folder, it may be necessary to skip non-markdown files, unless those files are listed in [`config.skip_render`](/docs/configuration#Directory); `themes/<your-theme>/source/` folder is not processed by this filter.

``` js
hexo.extend.filter.register('before_post_render', function(data) {
if (data.source.endsWith('.md') === false) return data;

data.title = data.title.toLowerCase();
return data;
});
Expand All @@ -112,12 +123,14 @@ Executed after a post is rendered. 실행 단계에 대해 더 알아보시길
아래 예시는 `@username`을 Twitter link로 대체하는 것을 보여줍니다.

``` js
hexo.extend.filter.register('after_post_render', function(data){
hexo.extend.filter.register('after_post_render', function(data) {
data.content = data.content.replace(/@(\d+)/, '<a href="http://twitter.com/$1">#$1</a>');
return data;
});
```

This filter matches every files in the `source/` folder, see [`before_post_render`](#before-post-render) section for more details.

### before_exit

Hexo가 종료되기 전에 실행됩니다. -- `hexo.exit`가 호출되는 즉시 실행됩니다.
Expand Down
17 changes: 15 additions & 2 deletions source/pt-br/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,18 @@ Executado antes de uma postagem ser renderizada. Verificar a seção [Renderizar
Por exemplo, para se transformar um título em _caixa baixa_:

``` js
hexo.extend.filter.register('before_post_render', function(data){
hexo.extend.filter.register('before_post_render', function(data) {
data.title = data.title.toLowerCase();
return data;
});
```

This filter matches every files in the `source/` folder, it may be necessary to skip non-markdown files, unless those files are listed in [`config.skip_render`](/docs/configuration#Directory); `themes/<your-theme>/source/` folder is not processed by this filter.

``` js
hexo.extend.filter.register('before_post_render', function(data) {
if (data.source.endsWith('.md') === false) return data;

data.title = data.title.toLowerCase();
return data;
});
Expand All @@ -112,12 +123,14 @@ Executado após a postagem ser renderizado. Verificar a seção [Renderizar](pos
Por exemplo, para substituir `@username` por um link para o perfil do Twitter:

``` js
hexo.extend.filter.register('after_post_render', function(data){
hexo.extend.filter.register('after_post_render', function(data) {
data.content = data.content.replace(/@(\d+)/, '<a href="http://twitter.com/$1">#$1</a>');
return data;
});
```

This filter matches every files in the `source/` folder, see [`before_post_render`](#before-post-render) section for more details.

### before_exit

Executado quando o Hexo está prestes a ser terminado -- isso será executado logo após `hexo.exit` ser chamado.
Expand Down
17 changes: 15 additions & 2 deletions source/ru/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,18 @@ hexo.extend.filter.unregister('example', require('path/to/filter'));
Например, перевести название в нижний регистр:

``` js
hexo.extend.filter.register('before_post_render', function(data){
hexo.extend.filter.register('before_post_render', function(data) {
data.title = data.title.toLowerCase();
return data;
});
```

This filter matches every files in the `source/` folder, it may be necessary to skip non-markdown files, unless those files are listed in [`config.skip_render`](/docs/configuration#Directory); `themes/<your-theme>/source/` folder is not processed by this filter.

``` js
hexo.extend.filter.register('before_post_render', function(data) {
if (data.source.endsWith('.md') === false) return data;

data.title = data.title.toLowerCase();
return data;
});
Expand All @@ -111,12 +122,14 @@ hexo.extend.filter.register('before_post_render', function(data){
Например, чтобы заменить `@username` ссылкой на профиль в Twitter:

``` js
hexo.extend.filter.register('after_post_render', function(data){
hexo.extend.filter.register('after_post_render', function(data) {
data.content = data.content.replace(/@(\d+)/, '<a href="http://twitter.com/$1">#$1</a>');
return data;
});
```

This filter matches every files in the `source/` folder, see [`before_post_render`](#before-post-render) section for more details.

### before_exit

Выполняется перед выходом из Hexo. Срабатывает сразу после выполнения `hexo.exit`.
Expand Down
17 changes: 15 additions & 2 deletions source/th/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,18 @@ execute ก่อนการ render ของโพสต์ สำหรั
ยกตัวอย่างเช่น การเปลี่ยนตัวอักษรเป็นตัวเล็ก:

``` js
hexo.extend.filter.register('before_post_render', function(data){
hexo.extend.filter.register('before_post_render', function(data) {
data.title = data.title.toLowerCase();
return data;
});
```

This filter matches every files in the `source/` folder, it may be necessary to skip non-markdown files, unless those files are listed in [`config.skip_render`](/docs/configuration#Directory); `themes/<your-theme>/source/` folder is not processed by this filter.

``` js
hexo.extend.filter.register('before_post_render', function(data) {
if (data.source.endsWith('.md') === false) return data;

data.title = data.title.toLowerCase();
return data;
});
Expand All @@ -113,12 +124,14 @@ execute หลังการ render ของโพสต์ สำหรับ
ยกตัวอย่างเช่น แทน `@username` ด้วยลิงค์ท่ีชึ้ไปถึงโปรไฟล์ของ Twitter

``` js
hexo.extend.filter.register('after_post_render', function(data){
hexo.extend.filter.register('after_post_render', function(data) {
data.content = data.content.replace(/@(\d+)/, '<a href="http://twitter.com/$1">#$1</a>');
return data;
});
```

This filter matches every files in the `source/` folder, see [`before_post_render`](#before-post-render) section for more details.

### before_exit

execute ก่อนการท่ีจะจบการใช้โปรแกรม hexo -- รันหลังการเรียก `hexo.exit`
Expand Down
17 changes: 15 additions & 2 deletions source/zh-cn/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,18 @@ hexo.extend.filter.unregister('example', require('path/to/filter'));
举例来说,把标题转为小写:

``` js
hexo.extend.filter.register('before_post_render', function(data){
hexo.extend.filter.register('before_post_render', function(data) {
data.title = data.title.toLowerCase();
return data;
});
```

This filter matches every files in the `source/` folder, it may be necessary to skip non-markdown files, unless those files are listed in [`config.skip_render`](/docs/configuration#Directory); `themes/<your-theme>/source/` folder is not processed by this filter.

``` js
hexo.extend.filter.register('before_post_render', function(data) {
if (data.source.endsWith('.md') === false) return data;

data.title = data.title.toLowerCase();
return data;
});
Expand All @@ -111,12 +122,14 @@ hexo.extend.filter.register('before_post_render', function(data){
举例来说,把 `@username` 取代为 Twitter 的开发者链接。

``` js
hexo.extend.filter.register('after_post_render', function(data){
hexo.extend.filter.register('after_post_render', function(data) {
data.content = data.content.replace(/@(\d+)/, '<a href="http://twitter.com/$1">#$1</a>');
return data;
});
```

This filter matches every files in the `source/` folder, see [`before_post_render`](#before-post-render) section for more details.

### before_exit

在 Hexo 即将结束时执行,也就是在 `hexo.exit` 被调用后执行。
Expand Down
17 changes: 15 additions & 2 deletions source/zh-tw/api/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,18 @@ hexo.extend.filter.unregister('example', require('path/to/filter'));
舉例來說,把標題轉為小寫:

``` js
hexo.extend.filter.register('before_post_render', function(data){
hexo.extend.filter.register('before_post_render', function(data) {
data.title = data.title.toLowerCase();
return data;
});
```

This filter matches every files in the `source/` folder, it may be necessary to skip non-markdown files, unless those files are listed in [`config.skip_render`](/docs/configuration#Directory); `themes/<your-theme>/source/` folder is not processed by this filter.

``` js
hexo.extend.filter.register('before_post_render', function(data) {
if (data.source.endsWith('.md') === false) return data;

data.title = data.title.toLowerCase();
return data;
});
Expand All @@ -111,12 +122,14 @@ hexo.extend.filter.register('before_post_render', function(data){
舉例來說,把 `@username` 取代為 Twitter 的使用者連結。

``` js
hexo.extend.filter.register('after_post_render', function(data){
hexo.extend.filter.register('after_post_render', function(data) {
data.content = data.content.replace(/@(\d+)/, '<a href="http://twitter.com/$1">#$1</a>');
return data;
});
```

This filter matches every files in the `source/` folder, see [`before_post_render`](#before-post-render) section for more details.

### before_exit

在 Hexo 即將結束時執行,也就是在 `hexo.exit` 被呼叫後執行。
Expand Down

0 comments on commit 62e2042

Please sign in to comment.