mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-24 21:48:02 +02:00
Run Prettier
This commit is contained in:
parent
a7b5148e06
commit
fbae29b0ff
29 changed files with 1311 additions and 987 deletions
|
@ -7,22 +7,23 @@
|
|||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
const CWD = process.cwd();
|
||||
const CWD = process.cwd();
|
||||
|
||||
const Metadata = require('../core/metadata.js');
|
||||
const fs = require('fs');
|
||||
const Metadata = require("../core/metadata.js");
|
||||
const fs = require("fs");
|
||||
let languages;
|
||||
if (fs.existsSync(CWD + '/languages.js')) {
|
||||
languages = require(CWD + '/languages.js');
|
||||
if (fs.existsSync(CWD + "/languages.js")) {
|
||||
languages = require(CWD + "/languages.js");
|
||||
} else {
|
||||
languages = [{
|
||||
enabled: true,
|
||||
name: 'English',
|
||||
tag: 'en',
|
||||
}];
|
||||
languages = [
|
||||
{
|
||||
enabled: true,
|
||||
name: "English",
|
||||
tag: "en"
|
||||
}
|
||||
];
|
||||
}
|
||||
function readCategories(layout) {
|
||||
|
||||
const enabledLanguages = [];
|
||||
languages.filter(lang => lang.enabled).map(lang => {
|
||||
enabledLanguages.push(lang.tag);
|
||||
|
@ -34,8 +35,7 @@ function readCategories(layout) {
|
|||
const language = enabledLanguages[k];
|
||||
|
||||
const metadatas = Metadata.filter(metadata => {
|
||||
return metadata.layout === layout &&
|
||||
metadata.language === language;
|
||||
return metadata.layout === layout && metadata.language === language;
|
||||
});
|
||||
|
||||
// Build a hashmap of article_id -> metadata
|
||||
|
@ -52,7 +52,7 @@ function readCategories(layout) {
|
|||
if (metadata.next) {
|
||||
if (!articles[metadata.next]) {
|
||||
throw new Error(
|
||||
'`next: ' + metadata.next + '` in ' + metadata.id + " doesn't exist"
|
||||
"`next: " + metadata.next + "` in " + metadata.id + " doesn't exist"
|
||||
);
|
||||
}
|
||||
previous[articles[metadata.next].id] = metadata.id;
|
||||
|
@ -79,7 +79,7 @@ function readCategories(layout) {
|
|||
currentCategory && categories.push(currentCategory);
|
||||
currentCategory = {
|
||||
name: metadata.category,
|
||||
links: [],
|
||||
links: []
|
||||
};
|
||||
}
|
||||
currentCategory.links.push(metadata);
|
||||
|
@ -91,15 +91,14 @@ function readCategories(layout) {
|
|||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
__dirname + '/../core/' + layout + 'Categories.js',
|
||||
'/**\n' +
|
||||
' * @generated\n' +
|
||||
' */\n' +
|
||||
'module.exports = ' +
|
||||
__dirname + "/../core/" + layout + "Categories.js",
|
||||
"/**\n" +
|
||||
" * @generated\n" +
|
||||
" */\n" +
|
||||
"module.exports = " +
|
||||
JSON.stringify(allCategories, null, 2) +
|
||||
';'
|
||||
";"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
module.exports = readCategories;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue