Skip to content

Commit ece53b4

Browse files
committed
fix: streamline imports in withSidebar component and update pathname handling in Sidebar
1 parent 1ebf202 commit ece53b4

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

apps/site/components/withSidebar.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
'use client';
22

33
import Sidebar from '@node-core/ui-components/Containers/Sidebar';
4-
import { usePathname } from 'next/navigation';
5-
import { useLocale, useTranslations } from 'next-intl';
4+
import { useTranslations } from 'next-intl';
65
import { useRef } from 'react';
76

87
import Link from '#site/components/Link';
9-
import { useClientContext } from '#site/hooks/client';
10-
import { useNavigationState } from '#site/hooks/client';
8+
import { useClientContext, useNavigationState } from '#site/hooks/client';
119
import { useSiteNavigation } from '#site/hooks/generic';
12-
import { useRouter } from '#site/navigation.mjs';
10+
import { useRouter, usePathname } from '#site/navigation.mjs';
1311

1412
import type { NavigationKeys } from '#site/types';
1513
import type { RichTranslationValues } from 'next-intl';
@@ -23,15 +21,12 @@ type WithSidebarProps = {
2321
const WithSidebar: FC<WithSidebarProps> = ({ navKeys, context, ...props }) => {
2422
const { getSideNavigation } = useSiteNavigation();
2523
const pathname = usePathname()!;
26-
const locale = useLocale();
2724
const t = useTranslations();
2825
const { push } = useRouter();
2926
const { frontmatter } = useClientContext();
3027
const sidebarRef = useRef<HTMLElement>(null);
3128
const sideNavigation = getSideNavigation(navKeys, context);
3229

33-
const localePathname = pathname.replace(`/${locale}`, '');
34-
3530
// Preserve sidebar scroll position across navigations
3631
useNavigationState('sidebar', sidebarRef);
3732

@@ -49,7 +44,7 @@ const WithSidebar: FC<WithSidebarProps> = ({ navKeys, context, ...props }) => {
4944
<Sidebar
5045
ref={sidebarRef}
5146
groups={mappedSidebarItems}
52-
pathname={localePathname}
47+
pathname={pathname}
5348
title={t('components.common.sidebar.title')}
5449
placeholder={frontmatter?.title}
5550
onSelect={push}

packages/ui-components/src/Containers/Sidebar/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,4 @@ const SideBar = forwardRef<HTMLElement, PropsWithChildren<SidebarProps>>(
6161
}
6262
);
6363

64-
SideBar.displayName = 'SideBar';
65-
6664
export default SideBar;

0 commit comments

Comments
 (0)