Skip to content

Commit

Permalink
add a per-post option
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed Nov 29, 2022
1 parent 2720e39 commit 7ab6f05
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/hexo/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ class Post {
data.slug = slugize((data.slug || data.title).toString(), { transform: config.filename_case });
data.layout = (data.layout || config.default_layout).toLowerCase();
data.date = data.date ? moment(data.date) : moment();
// Whether to allow async/concurrent rendering of tags within the post.
// Enabling it can improve performance for slow async tags, but may produce
// wrong results if tags within a post depend on each other.
data.async_tags = data.async_tags || false;

return Promise.all([
// Get the post path
Expand Down Expand Up @@ -413,6 +417,9 @@ class Post {
// If rendering is disabled, do nothing.
return cacheObj.restoreAllSwigTags(content);
}
if (!data.async_tags) {
return tag.render(cacheObj.restoreAllSwigTags(content), data);
}
// We'd like to render tags concurrently, so we split `content`
// by top-level HTML nodes that have swig tags into `split_content` array
// (nodes that don't have swig tags don't need to be split).
Expand Down

0 comments on commit 7ab6f05

Please sign in to comment.