Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from
Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/api-site-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ h1 {

`manifest` - Path to your web app manifest (e.g., `/manifest.json`). This will add a `<link>` tag to `<head>` with `rel` as `"manifest"` and `content` as the provided path.

`markdownOptions` - Override default [Remarkable options](https://github.com/jonschlinkert/remarkable#options) that will be used to render markdown.

`markdownPlugins` - An array of plugins to be loaded by Remarkable, the markdown parser and renderer used by Docusaurus. The plugin will receive a reference to the Remarkable instance, allowing custom parsing and rendering rules to be defined.

`ogImage` - Local path to an Open Graph image (e.g., `img/myImage.png`). This image will show up when your site is shared on Facebook and other websites/apps where the Open Graph protocol is supported.
Expand Down
16 changes: 14 additions & 2 deletions v1/lib/core/renderMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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-',
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 11 additions & 2 deletions v1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"description": "Easy to Maintain Open Source Documentation Websites",
"version": "1.4.0",
"license": "MIT",
"keywords": ["documentation", "websites", "open source", "docusaurus"],
"keywords": [
"documentation",
"websites",
"open source",
"docusaurus"
],
"repository": {
"type": "git",
"url": "https://github.com/facebook/Docusaurus.git"
Expand All @@ -14,7 +19,11 @@
"start": "cd website && yarn start"
},
"jest": {
"testPathIgnorePatterns": ["/node_modules/", "__fixtures__", "v2"],
"testPathIgnorePatterns": [
"/node_modules/",
"__fixtures__",
"v2"
],
"testURL": "http://localhost/"
},
"bin": {
Expand Down