Feat: add new Markdown parser (#39800)
and change all the challenges to new `md` format.
This commit is contained in:
committed by
GitHub
parent
a07f84c8ec
commit
0bd52f8bd1
18
tools/challenge-md-parser/mdx/plugins/add-frontmatter.js
Normal file
18
tools/challenge-md-parser/mdx/plugins/add-frontmatter.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const visit = require('unist-util-visit');
|
||||
const YAML = require('js-yaml');
|
||||
|
||||
function plugin() {
|
||||
return transformer;
|
||||
|
||||
function transformer(tree, file) {
|
||||
visit(tree, 'yaml', visitor);
|
||||
|
||||
function visitor(node) {
|
||||
const frontmatter = YAML.load(node.value);
|
||||
|
||||
file.data = { ...file.data, ...frontmatter };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = plugin;
|
Reference in New Issue
Block a user