Skip to content

Commit

Permalink
fix: 🐛 add default config, fix falsey values in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Reese committed Sep 27, 2020
1 parent 3c50244 commit c01e16e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
11 changes: 6 additions & 5 deletions packages/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ const plugin = {
frontmatter,
[extractFrontmatter, { name: 'frontmatter', yaml: yaml }],
remarkHtml,
plugin.config.useSyntaxHighlighting && [require('./rehype-shiki'),
typeof plugin.config.useSyntaxHighlighting === 'boolean' ?
{} :
plugin.config.useSyntaxHighlighting // its an options object
]
plugin.config.useSyntaxHighlighting && [
require('./rehype-shiki'),
typeof plugin.config.useSyntaxHighlighting === 'boolean' ? {} : plugin.config.useSyntaxHighlighting, // its an options object
],
];
}

Expand Down Expand Up @@ -96,6 +95,8 @@ const plugin = {
routes: [],
remarkPlugins: [], // if you define your own, you must define remarkHtml another html parser or you'll have issues. Order matters here.
useElderJsPluginImages: true, // if you are using the @elderjs/plugin-images it will replace all markdown images with the {{picture src="" alt="" /}} shortcode.
useSyntaxHighlighting: false, // available themes: https://github.com/shikijs/shiki/blob/master/packages/themes/README.md#literal-values - try material-theme-darker.
//theme is the only option available - for now.
},
shortcodes: [],
hooks: [
Expand Down
16 changes: 9 additions & 7 deletions packages/markdown/utils/prepareMarkdownParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ function prepareMarkdownParser(remarkPlugins = []) {
);
}

remarkPlugins.forEach((plugin) => {
if (Array.isArray(plugin)) {
processor.use(...plugin);
} else {
processor.use(plugin);
}
});
remarkPlugins
.filter((plugin) => !!plugin)
.forEach((plugin) => {
if (Array.isArray(plugin)) {
processor.use(...plugin);
} else {
processor.use(plugin);
}
});

return processor;
}
Expand Down

0 comments on commit c01e16e

Please sign in to comment.