mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-26 04:57:50 +02:00
chore(v2): use single method Lodash packages in docs plugin (#2519)
* chore(v2): use single method Lodash packages in docs plugin * reorder packages * TS types nightmare
This commit is contained in:
parent
36f4f9487e
commit
b4acb89888
4 changed files with 27 additions and 19 deletions
packages/docusaurus-plugin-content-docs/src
|
@ -5,7 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import flatMap from 'lodash.flatmap';
|
||||
import fs from 'fs-extra';
|
||||
import importFresh from 'import-fresh';
|
||||
import {
|
||||
|
@ -106,12 +106,12 @@ function normalizeItem(item: SidebarItemRaw): SidebarItem[] {
|
|||
];
|
||||
}
|
||||
if (isCategoryShorthand(item)) {
|
||||
return _.flatMap(normalizeCategoryShorthand(item), normalizeItem);
|
||||
return flatMap(normalizeCategoryShorthand(item), normalizeItem);
|
||||
}
|
||||
switch (item.type) {
|
||||
case 'category':
|
||||
assertIsCategory(item);
|
||||
return [{...item, items: _.flatMap(item.items, normalizeItem)}];
|
||||
return [{...item, items: flatMap(item.items, normalizeItem)}];
|
||||
case 'link':
|
||||
assertIsLink(item);
|
||||
return [item];
|
||||
|
@ -134,7 +134,7 @@ function normalizeSidebar(sidebars: SidebarRaw): Sidebar {
|
|||
? sidebar
|
||||
: normalizeCategoryShorthand(sidebar);
|
||||
|
||||
acc[sidebarId] = _.flatMap(normalizedSidebar, normalizeItem);
|
||||
acc[sidebarId] = flatMap(normalizedSidebar, normalizeItem);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue