Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
nunjucks.addFilter('body', file => {
return r.markSafe(fm(fs.readFileSync(path.join(process.cwd(), file)).toString()).body);
});
};
nunjucks.addFilter('markdown', value => {
return r.markSafe(md.render(value));
});
};
nunjucks.addFilter('render', file => {
let content = fs.readFileSync(path.join(process.cwd(), file));
const matter = fm(content.toString());
const ext = path.extname(file);
content = matter.body;
if (ext === '.md' || ext === '.markdown') {
content = md.render(content);
}
return r.markSafe(nunjucks.renderString(content, matter.attributes));
});
};