How to test render custom tag on single post HexoJS ? QA How to test render custom tag on single post HexoJS ?original disscussion at https://github.com/orgs/he
programming
snippet
,
typescript
,
javascript
,
script
,
hexo
QA
How to test render custom tag on single post HexoJS ?
original disscussion at https://github.com/orgs/hexojs/discussions/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 hexo generate
or hexo server
How to test render solution
solved using hexo.loadPlugin
and hexo.post.render
.
import Hexo from 'hexo';
import path from 'path';
const hexo = new Hexo(__dirname);
async function main() {
await hexo.init();
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();