fix: replace use of deepmerge with _.merge (#1430)

This commit is contained in:
Yangshun Tay 2019-05-02 08:00:28 -07:00 committed by Endi
parent 578c53a936
commit 64fdafbcea
5 changed files with 13 additions and 8 deletions

View file

@ -128,7 +128,7 @@ The default version for the site to be shown. If this is not set, the latest ver
#### `docsUrl` [string] #### `docsUrl` [string]
The base url for all docs file. Set this field to `''` to remove the `docs` prefix of the documentation URL. The base url for all docs file. Set this field to `''` to remove the `docs` prefix of the documentation URL.
If unset, it is defaulted to `docs`. If unset, it is defaulted to `docs`.
#### `disableHeaderTitle` [boolean] #### `disableHeaderTitle` [boolean]
@ -247,6 +247,10 @@ Hostname of your server. Useful if you are using GitHub Enterprise.
Path to your web app manifest (e.g., `manifest.json`). This will add a `<link>` tag to `<head>` with `rel` as `"manifest"` and `href` as the provided path. Path to your web app manifest (e.g., `manifest.json`). This will add a `<link>` tag to `<head>` with `rel` as `"manifest"` and `href` as the provided path.
#### `markdownOptions` [object]
Override default [Remarkable options](https://github.com/jonschlinkert/remarkable#options) that will be used to render markdown.
#### `markdownPlugins` [array] #### `markdownPlugins` [array]
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. 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.

View file

@ -5,11 +5,11 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*/ */
const _ = require('lodash');
const hljs = require('highlight.js'); const hljs = require('highlight.js');
const Markdown = require('remarkable'); const Markdown = require('remarkable');
const prismjs = require('prismjs'); const prismjs = require('prismjs');
const loadLanguages = require('prismjs/components/index'); const loadLanguages = require('prismjs/components/index');
const deepmerge = require('deepmerge');
const chalk = require('chalk'); const chalk = require('chalk');
const anchors = require('./anchors.js'); const anchors = require('./anchors.js');
@ -88,7 +88,7 @@ class MarkdownRenderer {
// Allow overriding default options // Allow overriding default options
if (siteConfig.markdownOptions) { if (siteConfig.markdownOptions) {
markdownOptions = deepmerge( markdownOptions = _.merge(
{}, {},
markdownOptions, markdownOptions,
siteConfig.markdownOptions, siteConfig.markdownOptions,

View file

@ -26,7 +26,7 @@ const fs = require('fs-extra');
const glob = require('glob'); const glob = require('glob');
const mkdirp = require('mkdirp'); const mkdirp = require('mkdirp');
const nodePath = require('path'); const nodePath = require('path');
const deepmerge = require('deepmerge'); const _ = require('lodash');
const readMetadata = require('./server/readMetadata.js'); const readMetadata = require('./server/readMetadata.js');
@ -43,7 +43,8 @@ let customTranslations = {
'pages-strings': {}, 'pages-strings': {},
}; };
if (fs.existsSync(`${CWD}/data/custom-translation-strings.json`)) { if (fs.existsSync(`${CWD}/data/custom-translation-strings.json`)) {
customTranslations = deepmerge( customTranslations = _.merge(
{},
JSON.parse( JSON.parse(
fs.readFileSync(`${CWD}/data/custom-translation-strings.json`, 'utf8'), fs.readFileSync(`${CWD}/data/custom-translation-strings.json`, 'utf8'),
), ),
@ -187,7 +188,8 @@ function execute() {
translations['pages-strings'], translations['pages-strings'],
customTranslations['pages-strings'], customTranslations['pages-strings'],
); );
translations['localized-strings'] = deepmerge( translations['localized-strings'] = _.merge(
{},
translations['localized-strings'], translations['localized-strings'],
customTranslations['localized-strings'], customTranslations['localized-strings'],
); );

View file

@ -44,7 +44,6 @@
"cross-spawn": "^6.0.5", "cross-spawn": "^6.0.5",
"crowdin-cli": "^0.3.0", "crowdin-cli": "^0.3.0",
"cssnano": "^3.10.0", "cssnano": "^3.10.0",
"deepmerge": "^2.1.1",
"escape-string-regexp": "^1.0.5", "escape-string-regexp": "^1.0.5",
"express": "^4.15.3", "express": "^4.15.3",
"feed": "^1.1.0", "feed": "^1.1.0",

View file

@ -21,7 +21,7 @@ function Layout(props) {
return ( return (
<React.Fragment> <React.Fragment>
<Head defaultTitle={`${defaultTitle} · ${tagline}`}> <Head defaultTitle={`${defaultTitle} · ${tagline}`}>
{title && <title>{title}</title>} {title && <title>{`${title} · ${tagline}`}</title>}
{favicon && <link rel="shortcut icon" href={baseUrl + favicon} />} {favicon && <link rel="shortcut icon" href={baseUrl + favicon} />}
</Head> </Head>
<Navbar /> <Navbar />