@@ -4,6 +4,7 @@ export * from "./use-collapsible"
|
||||
export * from "./use-collapsible-code-lines"
|
||||
export * from "./use-copy"
|
||||
export * from "./use-current-learning-path"
|
||||
export * from "./use-is-external-link"
|
||||
export * from "./use-is-browser"
|
||||
export * from "./use-keyboard-shortcut"
|
||||
export * from "./use-page-scroll-manager"
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { useMemo } from "react"
|
||||
|
||||
type UseIsExternalLinkProps = {
|
||||
href?: string
|
||||
}
|
||||
|
||||
export const useIsExternalLink = ({ href }: UseIsExternalLinkProps) => {
|
||||
const isExternal = useMemo(() => {
|
||||
return (
|
||||
href &&
|
||||
!href.startsWith("/") &&
|
||||
!href.startsWith("https://docs.medusajs.com") &&
|
||||
!href.startsWith("http://localhost:") &&
|
||||
!href.startsWith("#")
|
||||
)
|
||||
}, [href])
|
||||
|
||||
return isExternal
|
||||
}
|
||||
Reference in New Issue
Block a user