From 35c3bd6fb35998dc3623dfc509774bd7ebbf8852 Mon Sep 17 00:00:00 2001 From: endiliey Date: Fri, 23 Nov 2018 12:55:54 +0800 Subject: [PATCH] fix: docusaurus-version should work with subcategory --- 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); }); }); });