hexojs / hexojs/hexo

Concurrent rendering of nunjucks tags within a post

Open
#4,923 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
41.8k
Forks
41
PR merge metrics
No merged PRs in 30d

Description

## Check List

Please check followings before submitting a new feature request.

- [x] I have already read [Docs page](https://hexo.io/docs/)
- [x] I have already searched existing issues

## Feature Request

Currently, if we use [async rendering](https://hexo.io/api/tag.html#Async-Rendering) in custom tag plugins, rendering of tags can run concurrently __between posts__. However, tags __within the same post__ are still rendered sequentially.

This is because when rendering a post, hexo makes a [single `render` call](https://github.com/hexojs/hexo/blob/ba81258b5b6a1a7ae02033c056d82198c6d92ec9/lib/hexo/post.js#L425-L426) to nunjucks to render the entire post. Inside nunjucks, it renders all the tags sequentially.

I have a [custom tag plugin](https://github.com/ppwwyyxx/hexo-tag-vimhighlight) that needs to make expensive async calls, so it could benefit a lot from within-post async rendering of tags.

## Others

I have made a draft implementation of this feature at https://github.com/ppwwyyxx/hexo/commit/17565f7b1af33a8b71faab5ccb5b185125b4df32 . Instead of making one `render` call per-post, it finds each nunjucks tag in the post and call `render` on each of them.

This diff has improved my whole-site generation speed by __10x__.

I would like to hear:
* Whether the feature makes sense to add
* If the above is yes, whether my implementation is in the right direction. If so I could start a PR.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.