未验证 提交 737c25ed 编写于 作者: J Jiachi Liu 提交者: GitHub

doc: fix ActiveLink detection condition (#23472)



## Documentation / Examples

- [x] Make sure the linting passes


`router.pathname` can be dynamic routes like `/posts/[slug]`, use `router.asPath` instead to detect anchor is active
上级 9973b8cb
......@@ -17,7 +17,7 @@ function ActiveLink({ children, href }) {
const router = useRouter()
const style = {
marginRight: 10,
color: router.pathname === href ? 'red' : 'black',
color: router.asPath === href ? 'red' : 'black',
}
const handleClick = (e) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册