Files
reacord/packages/website/app/modules/navigation/app-link.tsx
2022-04-22 23:50:01 -05:00

33 lines
674 B
TypeScript

import type { ComponentPropsWithoutRef } from "react"
import { Link } from "@remix-run/react"
import { ExternalLink } from "~/modules/dom/external-link"
export type AppLinkProps = ComponentPropsWithoutRef<"a"> & {
type: "internal" | "external" | "router"
to: string
}
export function AppLink({ type, to, children, ...props }: AppLinkProps) {
if (type === "internal") {
return (
<a href={to} {...props}>
{children}
</a>
)
}
if (type === "external") {
return (
<ExternalLink href={to} {...props}>
{children}
</ExternalLink>
)
}
return (
<Link to={to} {...props}>
{children}
</Link>
)
}