-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"before_post_render", "after_post_render" executed on non-article page #4468
Comments
A possible reason is that all the js and css files in the source folder are judged as pages hexo/lib/plugins/processor/asset.js Lines 118 to 124 in 6437ff5
|
Interesting: $ hexo list page The |
hexo/lib/plugins/processor/asset.js Lines 114 to 120 in b7d15b9
renderable is defined in the pattern, maybe we can add some default value for skip_render |
Tested working. I add a test css in skip_render:
- '**.css' // should not show css
hexo.on('generateBefore', () => {
hexo.model('Page').toArray().forEach(i => console.log(i.path));
})
hexo.extend.filter.register('before_post_render', function(data){
if (data.source.endsWith('.md') === false) console.log(data.content.substring(0, 50))
return data;
});
hexo.extend.filter.register('after_post_render', function(data){
if (data.source.endsWith('.md') === false) console.log(data.content.substring(0, 50))
return data;
});
// should show css
hexo.extend.filter.register('after_render:css', function(str, data){
console.log(str.substring(0, 50))
console.log(data.path)
return str
}); This approach is not practical, every non-post patterns ( |
Lines 245 to 249 in b7d15b9
I tried: return promise.then(content => {
data.content = content;
// Run "before_post_render" filters
if (data.source && data.source.startsWith('_posts/')) return ctx.execFilter('before_post_render', data, { context: ctx });
return
}).then(() => { Then I realised backtick_code_block.js is a To ensure "backtick_code_block.js" still works, we may need a new filter "before_render". hexo.post.render(source, data); Looking at the docs, I notice |
Check List
Please check followings before submitting a new issue.
hexo version
to check)Expected behavior
before_post_render
andafter_post_render
should only executed on posts and pages.Actual behavior
Non-article files (like css) being processed by
before_post_render
&after_post_render
well.Is the problem still there under "Safe mode"?
Yes.
Other Information
Add following content to
scripts/test.js
:And non-article paths will show up.
hexojs/site#1506
cc @curbengh
The text was updated successfully, but these errors were encountered: