Skip to content

Commit

Permalink
[website]Fixed generate sidebar and full documentation (apache#9025)
Browse files Browse the repository at this point in the history
* Fixed generate sidebar and docs

* Fixed command
  • Loading branch information
tuteng authored Dec 22, 2020
1 parent 3604c67 commit 4da7a1b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 34 deletions.
66 changes: 33 additions & 33 deletions site2/website/docusaurus-version.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -147,42 +147,42 @@ require('@babel/register')({
});

// copy sidebar if necessary
if (versionFallback.diffLatestSidebar()) {
mkdirp(`${CWD}/versioned_sidebars`);
const sidebar = JSON.parse(fs.readFileSync(`${CWD}/sidebars.json`, 'utf8'));
const versioned = {};

Object.keys(sidebar).forEach(sb => {
const versionSidebar = `version-${version}-${sb}`;
versioned[versionSidebar] = {};

const categories = sidebar[sb];
Object.keys(categories).forEach(category => {
versioned[versionSidebar][category] = [];

const categoryItems = categories[category];
categoryItems.forEach(categoryItem => {
let versionedCategoryItem = categoryItem;
if (typeof categoryItem === 'object') {
if (categoryItem.ids && categoryItem.ids.length > 0) {
versionedCategoryItem.ids = categoryItem.ids.map(
id => `version-${version}-${id}`,
);
}
} else if (typeof categoryItem === 'string') {
versionedCategoryItem = `version-${version}-${categoryItem}`;
// if (versionFallback.diffLatestSidebar()) {
mkdirp(`${CWD}/versioned_sidebars`);
const sidebar = JSON.parse(fs.readFileSync(`${CWD}/sidebars.json`, 'utf8'));
const versioned = {};

Object.keys(sidebar).forEach(sb => {
const versionSidebar = `version-${version}-${sb}`;
versioned[versionSidebar] = {};

const categories = sidebar[sb];
Object.keys(categories).forEach(category => {
versioned[versionSidebar][category] = [];

const categoryItems = categories[category];
categoryItems.forEach(categoryItem => {
let versionedCategoryItem = categoryItem;
if (typeof categoryItem === 'object') {
if (categoryItem.ids && categoryItem.ids.length > 0) {
versionedCategoryItem.ids = categoryItem.ids.map(
id => `version-${version}-${id}`,
);
}
versioned[versionSidebar][category].push(versionedCategoryItem);
});
} else if (typeof categoryItem === 'string') {
versionedCategoryItem = `version-${version}-${categoryItem}`;
}
versioned[versionSidebar][category].push(versionedCategoryItem);
});
});

fs.writeFileSync(
`${CWD}/versioned_sidebars/version-${version}-sidebars.json`,
`${JSON.stringify(versioned, null, 2)}\n`,
'utf8',
);
}
});

fs.writeFileSync(
`${CWD}/versioned_sidebars/version-${version}-sidebars.json`,
`${JSON.stringify(versioned, null, 2)}\n`,
'utf8',
);
// }

// update versions.json file
versions.unshift(version);
Expand Down
2 changes: 1 addition & 1 deletion site2/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"build": "docusaurus-build",
"publish-gh-pages": "docusaurus-publish",
"write-translations": "docusaurus-write-translations",
"version": "cp docusaurus-version.js ./node_modules/.bin/ && docusaurus-version",
"version": "cp -r docusaurus-version.js ./node_modules/docusaurus/lib/version.js && docusaurus-version",
"rename-version": "docusaurus-rename-version",
"test": "jest --detectOpenHandles",
"crowdin-upload": "crowdin --config ../crowdin.yaml upload sources --auto-update -b master",
Expand Down

0 comments on commit 4da7a1b

Please sign in to comment.