Skip to content

Commit

Permalink
feat: 🎸 export remarkPlugins from package for easy importing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Reese committed May 19, 2021
1 parent 3a49b73 commit 296798a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ const extractFrontmatter = require('remark-extract-frontmatter');
const remarkFrontmatter = require('remark-frontmatter');
const yaml = require('yaml').parse;

const remarkPlugins = [
remarkFrontmatter,
[extractFrontmatter, { name: 'frontmatter', yaml: yaml }],
remarkSlug,
remarkHtml,
];

const plugin = {
name: '@elderjs/plugin-markdown',
description:
Expand All @@ -24,12 +31,7 @@ const plugin = {
const { openPattern, closePattern } = plugin.settings.shortcodes;

if (plugin.config.remarkPlugins.length === 0) {
plugin.config.remarkPlugins = [
remarkFrontmatter,
[extractFrontmatter, { name: 'frontmatter', yaml: yaml }],
remarkSlug,
remarkHtml,
];
plugin.config.remarkPlugins = remarkPlugins;
}

if (plugin.config.useSyntaxHighlighting) {
Expand Down Expand Up @@ -201,6 +203,7 @@ const plugin = {
},
},
],
remarkPlugins,
};

module.exports = plugin;
Expand Down

0 comments on commit 296798a

Please sign in to comment.