');
});
});
- test('Concatenated CSS files', async function() {
- const inputFiles = await glob(staticCSSDir + '/*.css');
- const combinedCSSFile =
- buildDir + '/' + siteConfig.projectName + '/css/main.css';
+ test('Concatenated CSS files', async () => {
+ const inputFiles = await glob(`${staticCSSDir}/*.css`);
+ const combinedCSSFile = `${buildDir}/${
+ siteConfig.projectName
+ }/css/main.css`;
const fileContents = await Promise.all(
[combinedCSSFile, ...inputFiles].map(file => fs.readFile(file, 'utf8'))
);
@@ -103,11 +103,11 @@ describe('Build files', () => {
});
});
- test('Copied assets from /docs/assets', function() {
+ test('Copied assets from /docs/assets', () => {
const metadata = outputAssetsFiles.map(file =>
filepath.create(file).basename()
);
- inputAssetsFiles.forEach(function(file) {
+ inputAssetsFiles.forEach(file => {
const path = filepath.create(file);
expect(metadata).toContain(path.basename());
});
diff --git a/lib/build-files.js b/lib/build-files.js
index 940669c4ce..83ed4ceaa9 100755
--- a/lib/build-files.js
+++ b/lib/build-files.js
@@ -10,7 +10,7 @@
require('babel-polyfill');
require('babel-register')({
babelrc: false,
- only: [__dirname, process.cwd() + '/core'],
+ only: [__dirname, `${process.cwd()}/core`],
plugins: [
require('./server/translate-plugin.js'),
'transform-class-properties',
@@ -25,7 +25,7 @@ const fs = require('fs');
const CWD = process.cwd();
-if (!fs.existsSync(CWD + '/siteConfig.js')) {
+if (!fs.existsSync(`${CWD}/siteConfig.js`)) {
console.error(
chalk.red('Error: No siteConfig.js file found in website folder!')
);
diff --git a/lib/copy-examples.js b/lib/copy-examples.js
index 72b6c2209d..1247b2c643 100755
--- a/lib/copy-examples.js
+++ b/lib/copy-examples.js
@@ -25,9 +25,9 @@ commander
.parse(process.argv);
// add scripts to package.json file
-if (fs.existsSync(CWD + '/package.json')) {
+if (fs.existsSync(`${CWD}/package.json`)) {
const packageContent = JSON.parse(
- fs.readFileSync(CWD + '/package.json', 'utf8')
+ fs.readFileSync(`${CWD}/package.json`, 'utf8')
);
if (!packageContent.scripts) {
packageContent.scripts = {};
@@ -41,8 +41,8 @@ if (fs.existsSync(CWD + '/package.json')) {
packageContent.scripts.version = 'docusaurus-version';
packageContent.scripts['rename-version'] = 'docusaurus-rename-version';
fs.writeFileSync(
- CWD + '/package.json',
- JSON.stringify(packageContent, null, 2) + '\n'
+ `${CWD}/package.json`,
+ `${JSON.stringify(packageContent, null, 2)}\n`
);
console.log(
`${chalk.green('Wrote docusaurus scripts to package.json file.')}\n`
@@ -59,17 +59,17 @@ let exampleSiteCreated = false;
if (feature === 'translations') {
// copy files for translations
const folder = path.join(__dirname, '..', 'examples', 'translations');
- if (fs.existsSync(CWD + '/../crowdin.yaml')) {
+ if (fs.existsSync(`${CWD}/../crowdin.yaml`)) {
console.log(
`${chalk.yellow('crowdin.yaml already exists')} in ${chalk.yellow(
- outerFolder + '/'
+ `${outerFolder}/`
)}. Rename or remove the file to regenerate an example version.\n`
);
} else {
- fs.copySync(folder + '/crowdin.yaml', CWD + '/../crowdin.yaml');
+ fs.copySync(`${folder}/crowdin.yaml`, `${CWD}/../crowdin.yaml`);
exampleSiteCreated = true;
}
- const files = glob.sync(folder + '/**/*');
+ const files = glob.sync(`${folder}/**/*`);
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
return;
@@ -87,9 +87,9 @@ if (feature === 'translations') {
} catch (e) {
console.log(
`${chalk.yellow(
- path.basename(filePath) + ' already exists'
+ `${path.basename(filePath)} already exists`
)} in ${chalk.yellow(
- 'website' + filePath.split(path.basename(filePath))[0]
+ `website${filePath.split(path.basename(filePath))[0]}`
)}. Rename or remove the file to regenerate an example version.\n`
);
}
@@ -97,7 +97,7 @@ if (feature === 'translations') {
} else if (feature === 'versions') {
// copy files for versions
const folder = path.join(__dirname, '..', 'examples', 'versions');
- const files = glob.sync(folder + '/**/*');
+ const files = glob.sync(`${folder}/**/*`);
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
return;
@@ -112,9 +112,9 @@ if (feature === 'translations') {
} catch (e) {
console.log(
`${chalk.yellow(
- path.basename(filePath) + ' already exists'
+ `${path.basename(filePath)} already exists`
)} in ${chalk.yellow(
- 'website' + filePath.split(path.basename(filePath))[0]
+ `website${filePath.split(path.basename(filePath))[0]}`
)}. Rename or remove the file to regenerate an example version.\n`
);
}
@@ -122,29 +122,29 @@ if (feature === 'translations') {
} else {
const folder = path.join(__dirname, '..', 'examples', 'basics');
// copy docs examples
- if (fs.existsSync(CWD + '/../docs-examples-from-docusaurus')) {
+ if (fs.existsSync(`${CWD}/../docs-examples-from-docusaurus`)) {
console.log(
`${chalk.yellow(
'Example docs already exist!'
)} Rename or remove ${chalk.yellow(
- outerFolder + '/docs-examples-from-docusaurus'
+ `${outerFolder}/docs-examples-from-docusaurus`
)} to regenerate example docs.\n`
);
} else {
fs.copySync(
- folder + '/docs-examples-from-docusaurus',
- CWD + '/../docs-examples-from-docusaurus'
+ `${folder}/docs-examples-from-docusaurus`,
+ `${CWD}/../docs-examples-from-docusaurus`
);
exampleSiteCreated = true;
docsCreated = true;
}
// copy blog examples
- if (fs.existsSync(CWD + '/blog-examples-from-docusaurus')) {
+ if (fs.existsSync(`${CWD}/blog-examples-from-docusaurus`)) {
console.log(
`${chalk.yellow(
'Example blog posts already exist!'
)} Rename or remove ${chalk.yellow(
- outerFolder + '/website/blog-examples-from-docusaurus'
+ `${outerFolder}/website/blog-examples-from-docusaurus`
)} to regenerate example blog posts.\n`
);
} else {
@@ -157,7 +157,7 @@ if (feature === 'translations') {
}
// copy .gitignore file
let gitignoreName = '.gitignore';
- if (fs.existsSync(CWD + '/../.gitignore')) {
+ if (fs.existsSync(`${CWD}/../.gitignore`)) {
gitignoreName = '.gitignore-example-from-docusaurus';
console.log(
`${chalk.yellow('.gitignore already exists')} in ${chalk.yellow(
@@ -167,11 +167,11 @@ if (feature === 'translations') {
}
fs.copySync(
path.join(folder, 'gitignore'),
- path.join(CWD, '/../' + gitignoreName)
+ path.join(CWD, `/../${gitignoreName}`)
);
// copy other files
- const files = glob.sync(folder + '/**/*');
+ const files = glob.sync(`${folder}/**/*`);
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
return;
@@ -194,9 +194,9 @@ if (feature === 'translations') {
} catch (e) {
console.log(
`${chalk.yellow(
- path.basename(filePath) + ' already exists'
+ `${path.basename(filePath)} already exists`
)} in ${chalk.yellow(
- 'website' + filePath.split(path.basename(filePath))[0]
+ `website${filePath.split(path.basename(filePath))[0]}`
)}. Rename or remove the file to regenerate an example version.\n`
);
}
@@ -221,9 +221,9 @@ if (feature === 'translations') {
if (docsCreated) {
console.log(
`Rename ${chalk.yellow(
- outerFolder + '/docs-examples-from-docusaurus'
+ `${outerFolder}/docs-examples-from-docusaurus`
)} to ${chalk.yellow(
- outerFolder + '/docs'
+ `${outerFolder}/docs`
)} to see the example docs on your site.\n`
);
}
@@ -231,9 +231,9 @@ if (docsCreated) {
if (blogCreated) {
console.log(
`Rename ${chalk.yellow(
- outerFolder + '/website/blog-examples-from-docusaurus'
+ `${outerFolder}/website/blog-examples-from-docusaurus`
)} to ${chalk.yellow(
- outerFolder + '/website/blog'
+ `${outerFolder}/website/blog`
)} to see the example blog posts on your site.\n`
);
}
diff --git a/lib/core/BlogPageLayout.js b/lib/core/BlogPageLayout.js
index 2ac9248b05..25098e6eec 100644
--- a/lib/core/BlogPageLayout.js
+++ b/lib/core/BlogPageLayout.js
@@ -16,9 +16,9 @@ const utils = require('./utils.js');
// used to generate entire blog pages, i.e. collection of truncated blog posts
class BlogPageLayout extends React.Component {
getPageURL(page) {
- let url = this.props.config.baseUrl + 'blog/';
+ let url = `${this.props.config.baseUrl}blog/`;
if (page > 0) {
- url += 'page' + (page + 1) + '/';
+ url += `page${page + 1}/`;
}
return url;
}
diff --git a/lib/core/BlogPost.js b/lib/core/BlogPost.js
index a75e4bc5e0..da61433d71 100644
--- a/lib/core/BlogPost.js
+++ b/lib/core/BlogPost.js
@@ -23,14 +23,10 @@ class BlogPost extends React.Component {
@@ -43,9 +39,9 @@ class BlogPost extends React.Component {
renderAuthorPhoto() {
const post = this.props.post;
- const className =
- 'authorPhoto' +
- (post.author && post.authorTitle ? ' authorPhotoBig' : '');
+ const className = `authorPhoto${
+ post.author && post.authorTitle ? ' authorPhotoBig' : ''
+ }`;
if (post.authorFBID || post.authorImageURL) {
const authorImageURL = post.authorFBID
? `https://graph.facebook.com/${
@@ -68,11 +64,10 @@ class BlogPost extends React.Component {
return (
diff --git a/lib/core/BlogPostLayout.js b/lib/core/BlogPostLayout.js
index d39325aceb..bec30776e5 100644
--- a/lib/core/BlogPostLayout.js
+++ b/lib/core/BlogPostLayout.js
@@ -38,12 +38,8 @@ class BlogPostLayout extends React.Component {
{/* Facebook SDK require 'fb-comments' class */}
@@ -109,7 +98,7 @@ class BlogPostLayout extends React.Component {
className={classNames('sideNavVisible', {
separateOnPageNav: hasOnPageNav,
})}
- url={'blog/' + post.path}
+ url={`blog/${post.path}`}
title={this.props.metadata.title}
language="en"
description={this.getDescription()}
@@ -132,7 +121,7 @@ class BlogPostLayout extends React.Component {
{this.renderSocialButtons()}
diff --git a/lib/core/BlogSidebar.js b/lib/core/BlogSidebar.js
index 80b52116ac..dfc3aaeb87 100644
--- a/lib/core/BlogSidebar.js
+++ b/lib/core/BlogSidebar.js
@@ -41,7 +41,7 @@ class BlogSidebar extends React.Component {
{translateThisDoc}
diff --git a/lib/core/Head.js b/lib/core/Head.js
index b939c3dc92..8f8c5f5d51 100644
--- a/lib/core/Head.js
+++ b/lib/core/Head.js
@@ -27,9 +27,9 @@ class Head extends React.Component {
}/styles/${highlight.theme}.min.css`;
// ensure the siteUrl variable ends with a single slash
- const siteUrl =
- (this.props.config.url + this.props.config.baseUrl).replace(/\/+$/, '') +
- '/';
+ const siteUrl = `${(
+ this.props.config.url + this.props.config.baseUrl
+ ).replace(/\/+$/, '')}/`;
return (
@@ -64,7 +64,7 @@ class Head extends React.Component {
)}
{this.props.config.noIndex && }
{this.props.redirect && (
-
)}
{hasBlog && (
)}
{this.props.config.gaTrackingId &&
@@ -167,13 +167,13 @@ class Head extends React.Component {
{this.props.config.usePrism && (
)}
{/* Site defined code. Keep these at the end to avoid overriding. */}
);
diff --git a/lib/core/Redirect.js b/lib/core/Redirect.js
index a719ee532a..2b3014bbb9 100644
--- a/lib/core/Redirect.js
+++ b/lib/core/Redirect.js
@@ -16,9 +16,9 @@ class Redirect extends React.Component {
? translation[this.props.language]['localized-strings'].tagline
: this.props.config.tagline;
const title = this.props.title
- ? this.props.title + ' · ' + this.props.config.title
+ ? `${this.props.title} · ${this.props.config.title}`
: (!this.props.config.disableTitleTagline &&
- this.props.config.title + ' · ' + tagline) ||
+ `${this.props.config.title} · ${tagline}`) ||
this.props.config.title;
const description = this.props.description || tagline;
const url =
diff --git a/lib/core/Site.js b/lib/core/Site.js
index d6037b0522..fa31cd36f6 100644
--- a/lib/core/Site.js
+++ b/lib/core/Site.js
@@ -11,7 +11,7 @@ const fs = require('fs');
const HeaderNav = require('./nav/HeaderNav.js');
const Head = require('./Head.js');
-const Footer = require(process.cwd() + '/core/Footer.js');
+const Footer = require(`${process.cwd()}/core/Footer.js`);
const translation = require('../server/translation.js');
const constants = require('./constants');
@@ -24,9 +24,9 @@ class Site extends React.Component {
? translation[this.props.language]['localized-strings'].tagline
: this.props.config.tagline;
const title = this.props.title
- ? this.props.title + ' · ' + this.props.config.title
+ ? `${this.props.title} · ${this.props.config.title}`
: (!this.props.config.disableTitleTagline &&
- this.props.config.title + ' · ' + tagline) ||
+ `${this.props.config.title} · ${tagline}`) ||
this.props.config.title;
const description = this.props.description || tagline;
const url =
@@ -35,8 +35,8 @@ class Site extends React.Component {
(this.props.url || 'index.html');
let docsVersion = this.props.version;
- if (!docsVersion && fs.existsSync(CWD + '/versions.json')) {
- const latestVersion = require(CWD + '/versions.json')[0];
+ if (!docsVersion && fs.existsSync(`${CWD}/versions.json`)) {
+ const latestVersion = require(`${CWD}/versions.json`)[0];
docsVersion = latestVersion;
}
diff --git a/lib/core/anchors.js b/lib/core/anchors.js
index ce6ec27bba..626a775db9 100644
--- a/lib/core/anchors.js
+++ b/lib/core/anchors.js
@@ -19,15 +19,9 @@ function anchors(md) {
if (textToken.content) {
const anchor = toSlug(textToken.content, env);
- return (
- ''
- );
+ return ``;
}
return originalRender(tokens, idx, options, env);
diff --git a/lib/core/nav/HeaderNav.js b/lib/core/nav/HeaderNav.js
index 7035074d8e..f4be273ccc 100644
--- a/lib/core/nav/HeaderNav.js
+++ b/lib/core/nav/HeaderNav.js
@@ -11,7 +11,7 @@ const React = require('react');
const fs = require('fs');
const classNames = require('classnames');
-const siteConfig = require(CWD + '/siteConfig.js');
+const siteConfig = require(`${CWD}/siteConfig.js`);
const translation = require('../../server/translation.js');
const env = require('../../server/env.js');
@@ -52,7 +52,7 @@ class LanguageDropDown extends React.Component {
`/${lang.tag}/`
);
} else if (this.props.current.id && this.props.current.id !== 'index') {
- href = siteConfig.baseUrl + lang.tag + '/' + this.props.current.id;
+ href = `${siteConfig.baseUrl + lang.tag}/${this.props.current.id}`;
}
return (
@@ -91,7 +91,7 @@ class LanguageDropDown extends React.Component {