Added option for client to include there own remarkable config (#974)

* Added option for client to include there own remarkable config

* Better use merge here

* Added lodash ...

* Change use of lodash to deepmerge and added description to api site

* markdownConfig -> markdownOptions

* Update api-site-config.md

* remove 1.4 docs change

 since it is unrelated (the feature will only be available in next release)

* Run prettier
This commit is contained in:
Marvin Heilemann 2018-09-20 09:00:59 +02:00 committed by Endilie Yacop Sucipto
parent 3c36a1cc8c
commit 8568a96e65
3 changed files with 27 additions and 4 deletions

View file

@ -8,6 +8,7 @@
const hljs = require('highlight.js');
const Markdown = require('remarkable');
const prismjs = require('prismjs');
const deepmerge = require('deepmerge');
const anchors = require('./anchors.js');
@ -21,7 +22,7 @@ class MarkdownRenderer {
constructor() {
const siteConfig = require(`${CWD}/siteConfig.js`);
const md = new Markdown({
let markdownOptions = {
// Highlight.js expects hljs css classes on the code element.
// This results in <pre><code class="hljs css languages-jsx">
langPrefix: 'hljs css language-',
@ -67,7 +68,18 @@ class MarkdownRenderer {
},
html: true,
linkify: true,
});
};
// Allow overriding default options
if (siteConfig.markdownOptions) {
markdownOptions = deepmerge(
{},
markdownOptions,
siteConfig.markdownOptions,
);
}
const md = new Markdown(markdownOptions);
// Register anchors plugin
md.use(anchors);