File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ export const BaseLink = forwardRef(function Link(
6767 const isPdf = url . isPdf ( href )
6868 const isExternal = url . isExternal ( href )
6969 const isInternalPdf = isPdf && ! isExternal
70+ const isHash = url . isHash ( href )
7071
7172 // Get proper download link for internally hosted PDF's & static files (ex: whitepaper)
7273 // Opens in separate window.
@@ -119,6 +120,27 @@ export const BaseLink = forwardRef(function Link(
119120 )
120121 }
121122
123+ if ( isHash ) {
124+ return (
125+ < ChakraLink
126+ onClick = { ( e ) => {
127+ e . stopPropagation ( )
128+ trackCustomEvent (
129+ customEventOptions ?? {
130+ eventCategory : "Link" ,
131+ eventAction : "Clicked" ,
132+ eventName : "Clicked on hash link" ,
133+ eventValue : href ,
134+ }
135+ )
136+ } }
137+ { ...commonProps }
138+ >
139+ { children }
140+ </ ChakraLink >
141+ )
142+ }
143+
122144 return (
123145 < NextLink
124146 locale = { locale }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { Box, type BoxProps } from "@chakra-ui/react"
33import { MAIN_CONTENT_ID } from "@/lib/constants"
44
55const MainArticle = ( props : BoxProps ) => (
6- < Box as = "article" id = { MAIN_CONTENT_ID } tabIndex = { - 1 } { ...props } />
6+ < Box as = "article" id = { MAIN_CONTENT_ID } scrollMarginTop = { 24 } { ...props } />
77)
88
99export default MainArticle
Original file line number Diff line number Diff line change 1- import React from "react "
1+ import { useTranslation } from "next-i18next "
22import { Box } from "@chakra-ui/react"
33
4- import { BaseLink } from ".. /components/Link"
4+ import { BaseLink } from "@ /components/Link"
55
6- import Translation from "./Translation "
6+ import { MAIN_CONTENT_ID } from "@/lib/constants "
77
8- export interface IProps {
9- hrefId : string
10- }
11-
12- export const SkipLink : React . FC < IProps > = ( { hrefId } ) => {
8+ export const SkipLink = ( ) => {
9+ const { t } = useTranslation ( )
1310 return (
1411 < Box bg = "primary.base" >
1512 < BaseLink
16- href = { hrefId }
13+ href = { "#" + MAIN_CONTENT_ID }
1714 lineHeight = "taller"
1815 position = "absolute"
1916 top = "-12"
@@ -23,7 +20,7 @@ export const SkipLink: React.FC<IProps> = ({ hrefId }) => {
2320 _hover = { { textDecoration : "none" } }
2421 _focus = { { position : "static" } }
2522 >
26- < Translation id = "skip-to-main-content" />
23+ { t ( "skip-to-main-content" ) }
2724 </ BaseLink >
2825 </ Box >
2926 )
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type { Root } from "@/lib/types"
88import FeedbackWidget from "@/components/FeedbackWidget"
99import Footer from "@/components/Footer"
1010import Nav from "@/components/Nav"
11+ import { SkipLink } from "@/components/SkipLink"
1112import TranslationBanner from "@/components/TranslationBanner"
1213import TranslationBannerLegal from "@/components/TranslationBannerLegal"
1314
@@ -47,6 +48,8 @@ export const RootLayout = ({
4748
4849 return (
4950 < Container mx = "auto" maxW = { oldTheme . variables . maxPageWidth } >
51+ < SkipLink />
52+
5053 < Nav path = { asPath } />
5154
5255 < TranslationBanner
Original file line number Diff line number Diff line change @@ -33,3 +33,5 @@ export const isHrefActive = (
3333 ? pathname . startsWith ( cleanHref )
3434 : pathname === cleanHref
3535}
36+
37+ export const isHash = ( href : string ) : boolean => href . startsWith ( "#" )
You can’t perform that action at this time.
0 commit comments