1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-04-26 14:08:29 -04:00
jarv.is/components/PageTitle/PageTitle.tsx

39 lines
849 B
TypeScript

import { useRouter } from "next/router";
import NextLink from "next/link";
import { styled } from "../../lib/styles/stitches.config";
import { baseUrl } from "../../lib/config";
import type { ComponentProps } from "react";
const Title = styled("h1", {
marginTop: 0,
marginBottom: "0.6em",
fontSize: "2em",
textAlign: "center",
"@medium": {
fontSize: "1.8em",
},
});
const Link = styled("a", {
color: "$text",
textDecoration: "none",
});
export type PageTitleProps = ComponentProps<typeof Title>;
const PageTitle = ({ children, ...rest }: PageTitleProps) => {
const router = useRouter();
const canonical = `${baseUrl}${router.pathname}/`;
return (
<Title {...rest}>
<NextLink href={canonical} passHref={true}>
<Link>{children}</Link>
</NextLink>
</Title>
);
};
export default PageTitle;