Skip to content

Commit 410df97

Browse files
committed
chore: refactor with LinkBox & LinkOverlay
1 parent a093da1 commit 410df97

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

src/components/DocsNav.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import type { DeveloperDocsLink } from "@/lib/interfaces"
77
import Emoji from "@/components/Emoji"
88

99
import { cn } from "@/lib/utils/cn"
10+
import { trackCustomEvent } from "@/lib/utils/matomo"
1011

1112
import docLinks from "@/data/developer-docs-links.yaml"
1213

1314
import { Flex, Stack } from "./ui/flex"
14-
import { BaseLink } from "./ui/Link"
15+
import { LinkBox, LinkOverlay } from "./ui/link-box"
1516

1617
import { useRtlFlip } from "@/hooks/useRtlFlip"
1718

@@ -43,19 +44,12 @@ const CardLink = ({ docData, isPrev, contentNotTranslated }: CardLinkProps) => {
4344
const { isRtl } = useRtlFlip()
4445

4546
return (
46-
<BaseLink
47-
href={docData.href}
47+
<LinkBox
4848
className={cn(
4949
"flex w-full flex-1 items-center no-underline",
5050
"h-[82px] rounded-sm border bg-background",
5151
isPrev ? "justify-start" : "justify-end"
5252
)}
53-
rel={isPrev ? "prev" : "next"}
54-
customEventOptions={{
55-
eventCategory: "next/previous article DocsNav",
56-
eventAction: "click",
57-
eventName: isPrev ? "previous" : "next",
58-
}}
5953
>
6054
<div className={cn("h-full p-4", isPrev ? "order-[0]" : "order-1")}>
6155
<Emoji
@@ -68,12 +62,22 @@ const CardLink = ({ docData, isPrev, contentNotTranslated }: CardLinkProps) => {
6862
</div>
6963
<TextDiv className={cn(!isPrev ? "pe-0 text-end" : "ps-0")}>
7064
<p className="uppercase text-body">{t(isPrev ? "previous" : "next")}</p>
71-
72-
<p className={cn("underline", isPrev ? "text-start" : "text-end")}>
65+
<LinkOverlay
66+
href={docData.href}
67+
onClick={() => {
68+
trackCustomEvent({
69+
eventCategory: "next/previous article DocsNav",
70+
eventAction: "click",
71+
eventName: isPrev ? "previous" : "next",
72+
})
73+
}}
74+
className={cn("underline", isPrev ? "text-start" : "text-end")}
75+
rel={isPrev ? "prev" : "next"}
76+
>
7377
{t(docData.id)}
74-
</p>
78+
</LinkOverlay>
7579
</TextDiv>
76-
</BaseLink>
80+
</LinkBox>
7781
)
7882
}
7983

0 commit comments

Comments
 (0)