You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ur...@apache.org on 2022/03/14 03:28:40 UTC
[pulsar-site] branch main updated: fix: optimize migrate script
This is an automated email from the ASF dual-hosted git repository.
urfree pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git
The following commit(s) were added to refs/heads/main by this push:
new 9b6256e fix: optimize migrate script
9b6256e is described below
commit 9b6256e9280f5e2cfda55fa9f3ed58563cfc9e62
Author: LiLi <ur...@apache.org>
AuthorDate: Mon Mar 14 11:28:30 2022 +0800
fix: optimize migrate script
Signed-off-by: LiLi <ur...@apache.org>
---
site2/website-next/migrate/migrate-chapter.js | 30 ++++++++++++++++++++-------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/site2/website-next/migrate/migrate-chapter.js b/site2/website-next/migrate/migrate-chapter.js
index 5f042fb..3ce7533 100644
--- a/site2/website-next/migrate/migrate-chapter.js
+++ b/site2/website-next/migrate/migrate-chapter.js
@@ -77,7 +77,11 @@ const migrate = (version, category, cb) => {
items: sidebar,
});
} else {
- categoryMap[category].items = sidebar;
+ categoryMap[category].items.concat(
+ sidebar.filter((item) => {
+ return !categoryMap[category].items.includes(item);
+ })
+ );
new_sidebar.docsSidebar = _.values(categoryMap);
}
} else {
@@ -116,13 +120,23 @@ const migrate = (version, category, cb) => {
// collapsed: true,
});
} else {
- categoryMap[category].items = sidebar.map((item) => {
- return {
- type: "doc",
- id:
- version_full + "/" + (item == "deploy-docs" ? "deploy-dcos" : item),
- };
- });
+ let _sbExists = _.keyBy(categoryMap[category].items, "id");
+ let _sb = sidebar
+ .map((item) => {
+ return {
+ type: "doc",
+ id:
+ version_full +
+ "/" +
+ (item == "deploy-docs" ? "deploy-dcos" : item),
+ };
+ })
+ .filter((item) => {
+ return !_sbExists[item.id];
+ });
+ if (_sb.length > 0) {
+ categoryMap[category].items = categoryMap[category].items.concat(_sb);
+ }
new_sidebar[version_full + "/docsSidebar"] = _.values(categoryMap);
}
}