1- import { ReactElement , ReactNode , useEffect , useMemo , useState } from "react" ;
1+ import { ReactElement , ReactNode , useMemo , useState } from "react" ;
22import type { NextPage } from "next" ;
33import type { AppProps } from "next/app" ;
44import Head from "next/head" ;
@@ -10,7 +10,6 @@ import StatusBadge from "@/common/StatusBadge";
1010import "../global-styles.css" ;
1111import createCache , { EmotionCache } from "@emotion/cache" ;
1212import { CacheProvider } from "@emotion/react" ;
13- import { usePathname } from "next/navigation" ;
1413import Link from "next/link" ;
1514import { GroupItem , Item , Section } from "../../../packages/lib/src/base-menu/types" ;
1615import { isGroupItem } from "../../../packages/lib/src/base-menu/utils" ;
@@ -29,10 +28,9 @@ const clientSideEmotionCache = createCache({ key: "css", prepend: true });
2928export default function App ( { Component, pageProps, emotionCache = clientSideEmotionCache } : AppPropsWithLayout ) {
3029 const getLayout = Component . getLayout || ( ( page ) => page ) ;
3130 const componentWithLayout = getLayout ( < Component { ...pageProps } /> ) ;
32- const router = useRouter ( ) ;
33- const pathname = usePathname ( ) ;
3431 const [ filter , setFilter ] = useState ( "" ) ;
3532 const [ isExpanded , setIsExpanded ] = useState ( true ) ;
33+ const { asPath : currentPath } = useRouter ( ) ;
3634
3735 const filterSections = ( sections : Section [ ] , query : string ) : Section [ ] => {
3836 const q = query . trim ( ) . toLowerCase ( ) ;
@@ -66,7 +64,7 @@ export default function App({ Component, pageProps, emotionCache = clientSideEmo
6664 const mapLinksToGroupItems = ( sections : LinksSectionDetails [ ] ) : Section [ ] => {
6765 const matchPaths = ( linkPath : string ) => {
6866 const desiredPaths = [ linkPath , `${ linkPath } /code` ] ;
69- const pathToBeMatched = pathname ?. split ( "#" ) [ 0 ] ?. slice ( 0 , - 1 ) ;
67+ const pathToBeMatched = currentPath ?. split ( "#" ) [ 0 ] ?. slice ( 0 , - 1 ) ;
7068 return pathToBeMatched ? desiredPaths . includes ( pathToBeMatched ) : false ;
7169 } ;
7270
@@ -88,16 +86,6 @@ export default function App({ Component, pageProps, emotionCache = clientSideEmo
8886 } ) ) ;
8987 } ;
9088
91- useEffect ( ( ) => {
92- const paths = [ ...new Set ( LinksSections . flatMap ( ( s ) => s . links . map ( ( l ) => l . path ) ) ) ] ;
93- const prefetchPaths = async ( ) => {
94- for ( const path of paths ) {
95- await router . prefetch ( path ) ;
96- }
97- } ;
98- void prefetchPaths ( ) ;
99- } , [ ] ) ;
100-
10189 // TODO: ADD NEW CATEGORIZATION
10290
10391 const filteredSections = useMemo ( ( ) => {
0 commit comments