From c01e16edbe2ad018fad862a75917e14b625a7407 Mon Sep 17 00:00:00 2001 From: Nick Reese Date: Sun, 27 Sep 2020 19:12:24 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20add=20default=20config,?= =?UTF-8?q?=20fix=20falsey=20values=20in=20parser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/markdown/index.js | 11 ++++++----- packages/markdown/utils/prepareMarkdownParser.js | 16 +++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/markdown/index.js b/packages/markdown/index.js index 13e39d0..a8f53bb 100644 --- a/packages/markdown/index.js +++ b/packages/markdown/index.js @@ -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 + ], ]; } @@ -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: [ diff --git a/packages/markdown/utils/prepareMarkdownParser.js b/packages/markdown/utils/prepareMarkdownParser.js index 3380ad0..03366cc 100644 --- a/packages/markdown/utils/prepareMarkdownParser.js +++ b/packages/markdown/utils/prepareMarkdownParser.js @@ -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; }