Skip to content

Commit

Permalink
🐛 fix: if activePath is null, use link value (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Apr 3, 2023
1 parent b720fc5 commit 66f0d36
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/components/Burger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ const Burger = () => {
className={styles.menu}
items={nav.map((item) => ({
label: <Link to={item.link}>{item.title}</Link>,
key: item.activePath!,
key: item.activePath! || item.link,
children:
item.activePath === activePath &&
(item.activePath || item.link) === activePath &&
sidebar?.map((group) => {
return (
!group.link && {
label: group.title,

type: 'group',
children: group.children.map((item) => ({
label: (
Expand Down
4 changes: 2 additions & 2 deletions src/slots/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const Navbar: FC = () => {
<>
<Tabs
onChange={(path) => {
const url = nav.find((i) => i.activePath === path)?.link;
const url = nav.find((i) => i.activePath === path || i.link === path)?.link;
if (!url) return;
history.push(url);
}}
Expand All @@ -71,7 +71,7 @@ const Navbar: FC = () => {
{item.title}
</Link>
),
key: item.activePath!,
key: item.activePath! || item.link,
}))}
/>

Expand Down
4 changes: 2 additions & 2 deletions src/store/selectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const activePathSel = (s: SiteStore) => {

const item = s.navData
.filter((i) => i.link !== '/')
.find((i) => s.location.pathname.startsWith(i.activePath!));
.find((i) => s.location.pathname.startsWith(i.activePath! || i.link));

return item?.activePath || '';
return item?.activePath || item?.link || '';
};

/**
Expand Down

0 comments on commit 66f0d36

Please sign in to comment.