How to test render custom tag on single post ? #5203
-
I was created my plugin custom shortcode. how to test render single post with plugin enabled ? i was used process.cwd = () => __dirname;
import Hexo from 'hexo';
import path from 'path';
const hexo = new Hexo(__dirname);
async function main() {
await hexo.init();
await hexo.load(() => {
//
});
const post = await hexo.render.render({ path: path.join(__dirname, 'source/lang/php.md') });
console.log(post);
}
main(); but the result not render the shortcode tag, how to do it? but my plugin is working when i call |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
Shouldn't you specify the engine in the render call? |
Beta Was this translation helpful? Give feedback.
-
oh maybe need load plugin like https://github.com/hexojs/hexo/blob/master/test/scripts/tags/blockquote.js |
Beta Was this translation helpful? Give feedback.
-
solved using import Hexo from 'hexo';
import path from 'path';
const hexo = new Hexo(__dirname);
async function main() {
await hexo.init().then(() => hexo.loadPlugin(require.resolve('hexo-shortcodes')));
await hexo.load(async () => {
const post = await hexo.post.render(path.join(__dirname, 'source/lang/php.md'));
console.log(post);
});
}
main(); |
Beta Was this translation helpful? Give feedback.
solved using
hexo.loadPlugin
andhexo.post.render
.