From 579cc61bbfc54d6895da9728fcabe399cb342d28 Mon Sep 17 00:00:00 2001 From: Endilie Yacop Sucipto Date: Fri, 23 Nov 2018 13:15:52 +0800 Subject: [PATCH] fix: docusaurus-version should work with subcategory (#1124) --- v1/lib/version.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/v1/lib/version.js b/v1/lib/version.js index a0eddc9cd0ff..fa6dee10dd1c 100755 --- a/v1/lib/version.js +++ b/v1/lib/version.js @@ -149,9 +149,19 @@ if (versionFallback.diffLatestSidebar()) { Object.keys(categories).forEach(category => { versioned[versionSidebar][category] = []; - const ids = categories[category]; - ids.forEach(id => { - versioned[versionSidebar][category].push(`version-${version}-${id}`); + 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}`; + } + versioned[versionSidebar][category].push(versionedCategoryItem); }); }); });