From ef7b86e87e69e05941ad438bb3bb306e5592acd7 Mon Sep 17 00:00:00 2001 From: Jonathan Summers-Muir Date: Wed, 16 Nov 2022 01:34:43 +0800 Subject: [PATCH] use Link --- .../NavigationMenu/NavigationMenu.tsx | 39 ++++++++-------- .../NavigationMenuGuideList.tsx | 44 ++++++++----------- apps/docs/pages/new/index.mdx | 22 +++++----- 3 files changed, 48 insertions(+), 57 deletions(-) diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx index 8141179783b..89514474c4b 100644 --- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx +++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.tsx @@ -1,3 +1,4 @@ +import Link from 'next/link' import { useRouter } from 'next/router' import { useState, useEffect } from 'react' import { IconChevronLeft } from '~/../../packages/ui' @@ -60,6 +61,8 @@ const SideNav = () => { } useEffect(() => { + console.log(router) + handleRouteChange(router.basePath + router.asPath) // Listen for page changes after a navigation or when the query changes router.events.on('routeChangeComplete', handleRouteChange) return () => { @@ -212,26 +215,22 @@ const SideNav = () => {
{section.map((link) => { return ( - { - // setLevel(link.level) - router.push(tempBasePath + link.href) - }} - > -
  • - - {link.label} -
  • -
    + + +
  • + + {link.label} +
  • +
    + ) })}
    diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx index 3d765484574..1fa4196a254 100644 --- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx +++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuGuideList.tsx @@ -1,3 +1,4 @@ +import Link from 'next/link' import { useRouter } from 'next/router' import rehypeFilter from 'react-markdown/lib/rehype-filter' import { IconChevronLeft } from '~/../../packages/ui' @@ -65,29 +66,23 @@ const NavigationMenuGuideList = ({ currentLevel, setLevel, tempBasePath, id }) = {x.items.map((x) => { return (
  • - { - router.push(`/${tempBasePath}${x.href}`) - }} - className="cursor-pointer transition text-scale-1000 text-sm hover:text-brand-900" - > - {x.name} - + + + {x.name} + +
  • ) })} ) : (
  • - { - router.push(`/${tempBasePath}${x.href}`) - }} - className="cursor-pointer transition text-scale-1000 text-sm hover:text-brand-900 flex gap-3" - > - {x.icon && } - {x.name} - + + + {x.icon && } + {x.name} + +
  • )} @@ -105,15 +100,12 @@ const NavigationMenuGuideList = ({ currentLevel, setLevel, tempBasePath, id }) = return (
  • - { - router.push(`/${tempBasePath}${x.href}`) - }} - className="cursor-pointer transition text-scale-1100 text-sm hover:text-brand-900 flex gap-3 my-1" - > - {x.icon && } - {x.name} - + + + {x.icon && } + {x.name} + +
  • ) diff --git a/apps/docs/pages/new/index.mdx b/apps/docs/pages/new/index.mdx index 3ad9fe6b221..426e8486b11 100644 --- a/apps/docs/pages/new/index.mdx +++ b/apps/docs/pages/new/index.mdx @@ -71,19 +71,19 @@ hello world return ( -