Fix versioning bugs

This commit is contained in:
Frank Li 2017-08-08 11:44:30 -07:00
parent 164fa390c2
commit b94dbff181
2 changed files with 11 additions and 4 deletions

View file

@ -213,7 +213,7 @@ function generateDocsMetadata() {
}
});
versionData = versionFallback.docData();
const versionData = versionFallback.docData();
versionData.forEach(metadata => {
const id = metadata.localized_id;
metadata.sidebar = order[id].sidebar;

View file

@ -14,10 +14,17 @@ const path = require("path");
const diff = require("diff");
const assert = require("assert");
const versions = require(CWD + "/versions.json");
const siteConfig = require(CWD + "/siteConfig.js");
const ENABLE_TRANSLATION = fs.existsSync(CWD + "/languages.js");
let versions;
if (fs.existsSync(CWD + "/versions.json")) {
versions = require(CWD + "/versions.json");
} else {
versions = [];
}
let languages;
if (fs.existsSync(CWD + "/languages.js")) {
languages = require(CWD + "/languages.js");
@ -76,7 +83,7 @@ const available = {};
// versionFiles is used to keep track of what file to use with a
// given version/id of a document
const versionFiles = {};
files = glob.sync(versionFolder + "**");
let files = glob.sync(versionFolder + "**");
files.forEach(file => {
const ext = path.extname(file);
if (ext !== ".md" && ext !== ".markdown") {
@ -188,7 +195,7 @@ function processVersionMetadata(file, version, useVersion, language) {
// return all metadata of versioned documents
function docData() {
allIds = new Set();
const allIds = new Set();
Object.keys(versionFiles).forEach(version => {
Object.keys(versionFiles[version]).forEach(id => {
allIds.add(id);