Skip to content

Commit

Permalink
fix: Remove nav items normalization
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Apr 22, 2024
1 parent 2e6a06a commit 2778728
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React, {ReactElement, useCallback, useEffect} from 'react';

import {
NavigationData,
NavigationDropdownItem,
NavigationItemModel,
PageConstructor,
PageConstructorProvider,
PageContent,
Expand Down Expand Up @@ -92,25 +90,6 @@ export function Page(props: DocInnerProps) {
);
}

function isDropdownItem(item: NavigationItemModel): item is NavigationDropdownItem {
return Array.isArray((item as NavigationDropdownItem).items);
}

function rebaseNavItem<T extends NavigationItemModel>(item: T) {
const result: T = {...item};

if (isDropdownItem(item)) {
(result as NavigationDropdownItem).items = item.items.map(rebaseNavItem);
}

// There can be also something like mobile://app.apk
if (item.url !== undefined && !item.url.match(/^[^/:]+:\/\//)) {
result.url = item.url.replace(/^\/?/, '/');
}

return result;
}

type TocData = DocPageData['toc'] & {
navigation?: NavigationData;
};
Expand Down Expand Up @@ -269,8 +248,8 @@ export function App(props: DocInnerProps): ReactElement {
? {
header: {
withBorder: true,
leftItems: leftItems.map(rebaseNavItem),
rightItems: rightItems.map(rebaseNavItem),
leftItems: leftItems,
rightItems: rightItems,
},
logo,
}
Expand Down

0 comments on commit 2778728

Please sign in to comment.