PR fixes
This commit is contained in:
@@ -5,6 +5,7 @@ import { startTransition, useCallback, useMemo } from "react"
|
||||
|
||||
import useRouterTransitionStore from "@/stores/router-transition"
|
||||
|
||||
import { useCheckIfExternalLink } from "@/hooks/useCheckIfExternalLink"
|
||||
import { trackClick, trackPageViewStart } from "@/utils/tracking"
|
||||
|
||||
import { linkVariants } from "./variants"
|
||||
@@ -55,6 +56,9 @@ export default function Link({
|
||||
return `${href}${search}`
|
||||
}, [href, searchParams, keepSearchParams])
|
||||
|
||||
// TODO: Remove this check (and hook) and only return <Link /> when current web is deleted
|
||||
const isExternal = useCheckIfExternalLink(href)
|
||||
|
||||
const startRouterTransition = useRouterTransitionStore(
|
||||
(state) => state.startRouterTransition
|
||||
)
|
||||
@@ -65,11 +69,17 @@ export default function Link({
|
||||
}
|
||||
}, [trackingId])
|
||||
|
||||
return (
|
||||
const linkProps = {
|
||||
href: fullUrl,
|
||||
className: classNames,
|
||||
}
|
||||
|
||||
return isExternal ? (
|
||||
<a {...linkProps} {...props} />
|
||||
) : (
|
||||
<NextLink
|
||||
scroll={scroll}
|
||||
prefetch={prefetch}
|
||||
className={classNames}
|
||||
onClick={(e) => {
|
||||
if (onClick) {
|
||||
onClick(e)
|
||||
@@ -94,9 +104,9 @@ export default function Link({
|
||||
router.push(fullUrl, { scroll })
|
||||
})
|
||||
}}
|
||||
href={fullUrl}
|
||||
id={trackingId}
|
||||
{...props}
|
||||
{...linkProps}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user