main
|
Last change
on this file since f14dc71 was 8ee4553, checked in by Bati <no-reply@…>, 7 months ago |
|
scaffold Vike app with Bati
|
-
Property mode
set to
100644
|
|
File size:
417 bytes
|
| Rev | Line | |
|---|
| [8ee4553] | 1 | import { usePageContext } from "vike-react/usePageContext";
|
|---|
| 2 |
|
|---|
| 3 | export function Link({ href, children }: { href: string; children: string }) {
|
|---|
| 4 | const pageContext = usePageContext();
|
|---|
| 5 | const { urlPathname } = pageContext;
|
|---|
| 6 | const isActive = href === "/" ? urlPathname === href : urlPathname.startsWith(href);
|
|---|
| 7 | return (
|
|---|
| 8 | <a href={href} className={isActive ? "is-active" : undefined}>
|
|---|
| 9 | {children}
|
|---|
| 10 | </a>
|
|---|
| 11 | );
|
|---|
| 12 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.