mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-13 00:57:53 +02:00
ESLintify Part 2 (#841)
* ESLintify Part 2 * Fix * Fix tests * Fix tests * Fix tests
This commit is contained in:
parent
4267337fb0
commit
5ac2cee658
42 changed files with 188 additions and 190 deletions
|
@ -158,7 +158,7 @@ async function execute() {
|
|||
rawContent = insertTableOfContents(rawContent);
|
||||
}
|
||||
|
||||
let defaultVersion = env.versioning.defaultVersion;
|
||||
const defaultVersion = env.versioning.defaultVersion;
|
||||
|
||||
// replace any links to markdown files to their website html links
|
||||
Object.keys(mdToHtml).forEach(key => {
|
||||
|
@ -250,7 +250,7 @@ async function execute() {
|
|||
.forEach(file => {
|
||||
// Why normalize? In case we are on Windows.
|
||||
// Remember the nuance of glob: https://www.npmjs.com/package/glob#windows
|
||||
let normalizedFile = path.normalize(file);
|
||||
const normalizedFile = path.normalize(file);
|
||||
const extension = path.extname(normalizedFile);
|
||||
if (extension !== '.md' && extension !== '.markdown') {
|
||||
return;
|
||||
|
@ -273,7 +273,7 @@ async function execute() {
|
|||
);
|
||||
metadata.id = metadata.title;
|
||||
|
||||
let language = 'en';
|
||||
const language = 'en';
|
||||
const blogPostComp = (
|
||||
<BlogPostLayout
|
||||
metadata={metadata}
|
||||
|
@ -284,15 +284,15 @@ async function execute() {
|
|||
);
|
||||
const str = renderToStaticMarkupWithDoctype(blogPostComp);
|
||||
|
||||
let targetFile = join(buildDir, 'blog', filePath);
|
||||
const targetFile = join(buildDir, 'blog', filePath);
|
||||
writeFileAndCreateFolder(targetFile, str);
|
||||
});
|
||||
// create html files for all blog pages (collections of article previews)
|
||||
const BlogPageLayout = require('../core/BlogPageLayout.js');
|
||||
const perPage = 10;
|
||||
for (let page = 0; page < Math.ceil(MetadataBlog.length / perPage); page++) {
|
||||
let language = 'en';
|
||||
const metadata = {page: page, perPage: perPage};
|
||||
const language = 'en';
|
||||
const metadata = {page, perPage};
|
||||
const blogPageComp = (
|
||||
<BlogPageLayout
|
||||
metadata={metadata}
|
||||
|
@ -302,7 +302,7 @@ async function execute() {
|
|||
);
|
||||
const str = renderToStaticMarkupWithDoctype(blogPageComp);
|
||||
|
||||
let targetFile = join(
|
||||
const targetFile = join(
|
||||
buildDir,
|
||||
'blog',
|
||||
page > 0 ? 'page' + (page + 1) : '',
|
||||
|
@ -389,7 +389,7 @@ async function execute() {
|
|||
files.forEach(file => {
|
||||
// Why normalize? In case we are on Windows.
|
||||
// Remember the nuance of glob: https://www.npmjs.com/package/glob#windows
|
||||
let normalizedFile = path.normalize(file);
|
||||
const normalizedFile = path.normalize(file);
|
||||
// parse css files to replace colors and fonts according to siteConfig
|
||||
if (normalizedFile.match(/\.css$/) && !isSeparateCss(normalizedFile)) {
|
||||
const mainCss = join(buildDir, 'css', 'main.css');
|
||||
|
@ -453,7 +453,7 @@ async function execute() {
|
|||
files.forEach(file => {
|
||||
// Why normalize? In case we are on Windows.
|
||||
// Remember the nuance of glob: https://www.npmjs.com/package/glob#windows
|
||||
let normalizedFile = path.normalize(file);
|
||||
const normalizedFile = path.normalize(file);
|
||||
// render .js files to strings
|
||||
if (normalizedFile.match(/\.js$/)) {
|
||||
const pageID = path.basename(normalizedFile, '.js');
|
||||
|
@ -511,7 +511,7 @@ async function execute() {
|
|||
}
|
||||
|
||||
// write to base level
|
||||
let language = env.translation.enabled ? 'en' : '';
|
||||
const language = env.translation.enabled ? 'en' : '';
|
||||
translate.setLanguage(language);
|
||||
const str = renderToStaticMarkupWithDoctype(
|
||||
<Site
|
||||
|
@ -529,7 +529,7 @@ async function execute() {
|
|||
);
|
||||
} else {
|
||||
// allow for rendering of other files not in pages/en folder
|
||||
let language = env.translation.enabled ? 'en' : '';
|
||||
const language = env.translation.enabled ? 'en' : '';
|
||||
translate.setLanguage(language);
|
||||
const str = renderToStaticMarkupWithDoctype(
|
||||
<Site
|
||||
|
@ -564,8 +564,8 @@ async function execute() {
|
|||
writeFileAndCreateFolder(targetFile, str);
|
||||
} else if (!fs.lstatSync(normalizedFile).isDirectory()) {
|
||||
// copy other non .js files
|
||||
let parts = normalizedFile.split('pages');
|
||||
let targetFile = join(buildDir, parts[1]);
|
||||
const parts = normalizedFile.split('pages');
|
||||
const targetFile = join(buildDir, parts[1]);
|
||||
mkdirp.sync(path.dirname(targetFile));
|
||||
fs.copySync(normalizedFile, targetFile);
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ async function execute() {
|
|||
|
||||
// Generate CNAME file if a custom domain is specified in siteConfig
|
||||
if (siteConfig.cname) {
|
||||
let targetFile = join(buildDir, 'CNAME');
|
||||
const targetFile = join(buildDir, 'CNAME');
|
||||
fs.writeFileSync(targetFile, siteConfig.cname);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue