mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
Initial changes to error messages
This commit is contained in:
parent
e285f93c1b
commit
b256d2f8d9
7 changed files with 45 additions and 6 deletions
|
@ -11,10 +11,22 @@
|
||||||
|
|
||||||
require("babel-register")({
|
require("babel-register")({
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
only: [__dirname, process.cwd() + "/core"],
|
only: [__dirname, process.cwd() + "/core"],
|
||||||
plugins: [require("./server/translate-plugin.js")],
|
plugins: [require("./server/translate-plugin.js")],
|
||||||
presets: ["react", "latest"]
|
presets: ["react", "latest"]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// initial check that required files are present
|
||||||
|
const chalk = require("chalk");
|
||||||
|
const fs = require("fs");
|
||||||
|
const CWD = process.cwd();
|
||||||
|
|
||||||
|
if (!fs.existsSync(CWD + "/siteConfig.js")) {
|
||||||
|
console.error(
|
||||||
|
chalk.red("Error: No siteConfig.js file found in website folder!")
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const generate = require("./server/generate.js");
|
const generate = require("./server/generate.js");
|
||||||
generate();
|
generate();
|
||||||
|
|
|
@ -128,6 +128,12 @@ class HeaderNav extends React.Component {
|
||||||
"-" +
|
"-" +
|
||||||
link.doc;
|
link.doc;
|
||||||
}
|
}
|
||||||
|
if (!Metadata[id]) {
|
||||||
|
throw new Error(
|
||||||
|
"A headerLink is specified with a document that does not exist. No document exists with id: " +
|
||||||
|
link.doc
|
||||||
|
);
|
||||||
|
}
|
||||||
href = this.props.config.baseUrl + Metadata[id].permalink;
|
href = this.props.config.baseUrl + Metadata[id].permalink;
|
||||||
} else if (link.page) {
|
} else if (link.page) {
|
||||||
if (fs.existsSync(CWD + "/pages/en/" + link.page + ".js")) {
|
if (fs.existsSync(CWD + "/pages/en/" + link.page + ".js")) {
|
||||||
|
|
|
@ -56,7 +56,7 @@ function readCategories(sidebar) {
|
||||||
if (metadata.next) {
|
if (metadata.next) {
|
||||||
if (!articles[metadata.next]) {
|
if (!articles[metadata.next]) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"`next: " + metadata.next + "` in " + metadata.id + " doesn't exist"
|
"Improper sidebars.json file. Make sure that documents with the ids specified in sidebars.json exist and that no ids are repeated."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
previous[articles[metadata.next].id] = metadata.id;
|
previous[articles[metadata.next].id] = metadata.id;
|
||||||
|
|
|
@ -32,7 +32,12 @@ if (fs.existsSync(CWD + "/languages.js")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function readSidebar() {
|
function readSidebar() {
|
||||||
let allSidebars = require(CWD + "/sidebars.json");
|
let allSidebars;
|
||||||
|
if (fs.existsSync(CWD + "/sidebars.json")) {
|
||||||
|
allSidebars = require(CWD + "/sidebars.json");
|
||||||
|
} else {
|
||||||
|
allSidebars = {};
|
||||||
|
}
|
||||||
Object.assign(allSidebars, versionFallback.sidebarData());
|
Object.assign(allSidebars, versionFallback.sidebarData());
|
||||||
|
|
||||||
const order = {};
|
const order = {};
|
||||||
|
@ -155,7 +160,7 @@ function processMetadata(file) {
|
||||||
metadata.previous = language + "-" + order[id].previous;
|
metadata.previous = language + "-" + order[id].previous;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { metadata, rawContent: rawContent };
|
return { metadata, rawContent: rawContent };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,6 +157,10 @@ function execute(port) {
|
||||||
});
|
});
|
||||||
|
|
||||||
const metadata = Metadata[links[url]];
|
const metadata = Metadata[links[url]];
|
||||||
|
if (!metadata) {
|
||||||
|
next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const language = metadata.language;
|
const language = metadata.language;
|
||||||
|
|
||||||
let file;
|
let file;
|
||||||
|
@ -438,7 +442,6 @@ function execute(port) {
|
||||||
res.send(cssContent);
|
res.send(cssContent);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* serve static content first from user folder then from docusaurus */
|
|
||||||
app.use(
|
app.use(
|
||||||
siteConfig.baseUrl + "docs/assets/",
|
siteConfig.baseUrl + "docs/assets/",
|
||||||
express.static(CWD + "/../docs/assets")
|
express.static(CWD + "/../docs/assets")
|
||||||
|
|
|
@ -11,11 +11,23 @@
|
||||||
|
|
||||||
require("babel-register")({
|
require("babel-register")({
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
only: [__dirname, process.cwd() + "/core"],
|
only: [__dirname, process.cwd() + "/core"],
|
||||||
plugins: [require("./server/translate-plugin.js")],
|
plugins: [require("./server/translate-plugin.js")],
|
||||||
presets: ["react", "latest"]
|
presets: ["react", "latest"]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// initial check that required files are present
|
||||||
|
const chalk = require("chalk");
|
||||||
|
const fs = require("fs");
|
||||||
|
const CWD = process.cwd();
|
||||||
|
|
||||||
|
if (!fs.existsSync(CWD + "/siteConfig.js")) {
|
||||||
|
console.error(
|
||||||
|
chalk.red("Error: No siteConfig.js file found in website folder!")
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const program = require("commander");
|
const program = require("commander");
|
||||||
|
|
||||||
program.option("--port <number>", "Specify port number").parse(process.argv);
|
program.option("--port <number>", "Specify port number").parse(process.argv);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"babel-register": "^6.24.1",
|
"babel-register": "^6.24.1",
|
||||||
"babel-traverse": "^6.25.0",
|
"babel-traverse": "^6.25.0",
|
||||||
"babylon": "^6.17.4",
|
"babylon": "^6.17.4",
|
||||||
|
"chalk": "^2.1.0",
|
||||||
"classnames": "^2.2.5",
|
"classnames": "^2.2.5",
|
||||||
"commander": "^2.11.0",
|
"commander": "^2.11.0",
|
||||||
"diff": "^3.3.0",
|
"diff": "^3.3.0",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue