Change navigation headline to allow href attributes

This commit is contained in:
Arnie 2023-06-02 13:44:11 +02:00
parent ad183bbc0e
commit c414b7d1f2

View File

@ -15,17 +15,25 @@ const Link = styled(RouterLink)({
textDecoration: "none",
});
type NavigationHeadlineProps = Partial<Pick<RouterLinkProps, "to">>;
type NavigationHeadlineProps =
| (Partial<Pick<RouterLinkProps, "to">> & {
href?: undefined;
})
| {
href?: string;
to?: undefined;
};
const NavigationHeadline: React.FC<
React.PropsWithChildren<NavigationHeadlineProps>
> = (props) => {
const { children, to } = props;
const { children, href, to } = props;
return (
<Headline>
{to && <Link to={to}>{children}</Link>}
{!to && children}
{href && <a href={href}>{children}</a>}
{!to && !href && children}
</Headline>
);
};