mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
Allow the docs not to just be in a folder called docs
Also: - regex escaping - update api documentation
This commit is contained in:
parent
dc0c1390c4
commit
e273dfc13b
5 changed files with 25 additions and 9 deletions
|
@ -13,6 +13,7 @@ const glob = require("glob");
|
|||
const chalk = require("chalk");
|
||||
const siteConfig = require(CWD + "/siteConfig.js");
|
||||
const versionFallback = require("./versionFallback.js");
|
||||
const escapeStringRegexp = require("escape-string-regexp");
|
||||
|
||||
const ENABLE_VERSIONING = fs.existsSync(CWD + "/versions.json");
|
||||
|
||||
|
@ -31,13 +32,15 @@ if (fs.existsSync(CWD + "/languages.js")) {
|
|||
];
|
||||
}
|
||||
|
||||
// Can add additional path information to the docs folder
|
||||
// Can have a custom docs path. Top level folder still needs to be in directory
|
||||
// at the same level as `website`, not inside `website`.
|
||||
// e.g., docs/whereDocsReallyExist
|
||||
// website-docs/
|
||||
// All .md docs still (currently) must be in one flat directory hierarchy.
|
||||
// e.g., docs/whereDocsReallyExist/*.md (all .md files in this dir)
|
||||
function getDocsPath() {
|
||||
return siteConfig.docsAdditionalPath
|
||||
? "docs" + siteConfig.docsAdditionalPath
|
||||
return siteConfig.customDocsPath
|
||||
? siteConfig.customDocsPath
|
||||
: "docs";
|
||||
}
|
||||
// returns map from id to object containing sidebar ordering info
|
||||
|
@ -125,7 +128,7 @@ function extractMetadata(content) {
|
|||
function processMetadata(file) {
|
||||
const result = extractMetadata(fs.readFileSync(file, "utf8"));
|
||||
|
||||
let regexSubFolder = new RegExp("/" + getDocsPath() + "\/(.*)\/.*/");
|
||||
let regexSubFolder = new RegExp("/" + escapeStringRegexp(getDocsPath()) + "\/(.*)\/.*/");
|
||||
|
||||
let language = "en";
|
||||
const match = regexSubFolder.exec(file);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue