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 3 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.

`markdownConfig` - The config [remarkable](https://github.com/jonschlinkert/remarkable) will use to render markdown. Config option can be found here: https://github.com/jonschlinkert/remarkable#options.

`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
12 changes: 10 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 _ = require("lodash");

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 markdownConfig = {
// 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,14 @@ class MarkdownRenderer {
},
html: true,
linkify: true,
});
};

// Allow client to use there own config
if (siteConfig.markdownConfig) {
markdownConfig = _.merge({}, markdownConfig, siteConfig.markdownConfig);
muuvmuuv marked this conversation as resolved.
Show resolved Hide resolved
}

const md = new Markdown(markdownConfig);

// Register anchors plugin
md.use(anchors);
Expand Down
14 changes: 12 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 Expand Up @@ -56,6 +65,7 @@
"imagemin-jpegtran": "^5.0.2",
"imagemin-optipng": "^5.2.1",
"imagemin-svgo": "^6.0.0",
"lodash": "^4.17.11",
"markdown-toc": "^1.2.0",
"mkdirp": "^0.5.1",
"portfinder": "^1.0.17",
Expand Down
2 changes: 1 addition & 1 deletion v1/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4634,7 +4634,7 @@ lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"

lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.3.0, lodash@~4.17.10:
lodash@^4.13.1, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.3.0, lodash@~4.17.10:
version "4.17.11"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"

Expand Down