diff --git a/components/Footer/Footer.tsx b/components/Footer/Footer.tsx index 0b9aa354..112c66c4 100644 --- a/components/Footer/Footer.tsx +++ b/components/Footer/Footer.tsx @@ -35,7 +35,7 @@ const Row = styled("div", { }, }); -const Link = styled("a", { +const Link = styled(NextLink, { color: "$mediumDark", textDecoration: "none", }); @@ -88,13 +88,13 @@ const Footer = ({ ...rest }: FooterProps) => (
Content{" "} - - licensed under CC-BY-4.0 - + + licensed under CC-BY-4.0 + ,{" "} - - 2001 - {" "} + + 2001 + {" "} – {new Date(process.env.NEXT_PUBLIC_RELEASE_DATE).getUTCFullYear()}.
diff --git a/components/Link/Link.tsx b/components/Link/Link.tsx index 9a6a24a3..5f24229d 100644 --- a/components/Link/Link.tsx +++ b/components/Link/Link.tsx @@ -4,7 +4,7 @@ import { styled } from "../../lib/styles/stitches.config"; import type { ComponentProps } from "react"; import type { LinkProps as NextLinkProps } from "next/link"; -const FancyLink = styled("a", { +const StyledLink = styled(NextLink, { color: "$link", textDecoration: "none", @@ -34,29 +34,20 @@ const FancyLink = styled("a", { }, }); -export type LinkProps = Omit, "href"> & +export type LinkProps = Omit, "href"> & NextLinkProps & { underline?: boolean; forceNewWindow?: boolean; }; -const Link = ({ - href, - prefetch = false, - passHref = true, - target, - rel, - underline = true, - forceNewWindow, - ...rest -}: LinkProps) => { +const Link = ({ href, prefetch = false, target, rel, underline = true, forceNewWindow, ...rest }: LinkProps) => { // this component auto-detects whether or not we should use a normal HTML anchor externally or next/link internally, // can be overridden with `forceNewWindow={true}`. const isExternal = isAbsoluteUrl(href.toString()); if (forceNewWindow || isExternal) { return ( - ); - } else { - return ( - - - - ); } + + return ; }; export default Link; diff --git a/components/MenuItem/MenuItem.tsx b/components/MenuItem/MenuItem.tsx index 99ea1193..468d443d 100644 --- a/components/MenuItem/MenuItem.tsx +++ b/components/MenuItem/MenuItem.tsx @@ -1,7 +1,7 @@ import NextLink from "next/link"; import { styled } from "../../lib/styles/stitches.config"; -const Link = styled("a", { +const Link = styled(NextLink, { display: "inline-block", color: "$mediumDark", textDecoration: "none", @@ -67,11 +67,9 @@ const MenuItem = ({ icon: ItemIcon, href, text, current, className }: MenuItemPr // allow both navigational links and/or other interactive react components (e.g. the theme toggle) if (href) { return ( - - - {linkContent} - - + + {linkContent} + ); } else { return linkContent; diff --git a/components/NoteMeta/NoteMeta.tsx b/components/NoteMeta/NoteMeta.tsx index 6c48ee87..ed744bea 100644 --- a/components/NoteMeta/NoteMeta.tsx +++ b/components/NoteMeta/NoteMeta.tsx @@ -22,7 +22,7 @@ const MetaItem = styled("div", { whiteSpace: "nowrap", }); -const MetaLink = styled("a", { +const MetaLink = styled(NextLink, { color: "inherit", textDecoration: "none", }); @@ -62,20 +62,17 @@ const NoteMeta = ({ slug, date, title, htmlTitle, tags = [] }: NoteMetaProps) => <> - - - - - - - + + + + {tags.length > 0 && ( diff --git a/components/NoteTitle/NoteTitle.tsx b/components/NoteTitle/NoteTitle.tsx index e730e513..88dc30dc 100644 --- a/components/NoteTitle/NoteTitle.tsx +++ b/components/NoteTitle/NoteTitle.tsx @@ -18,7 +18,7 @@ const Title = styled("h1", { }, }); -const Link = styled("a", { +const Link = styled(NextLink, { color: "$text", textDecoration: "none", }); @@ -27,15 +27,13 @@ export type NoteTitleProps = Pick & Compo const NoteTitle = ({ slug, htmlTitle, ...rest }: NoteTitleProps) => ( - <NextLink + <Link href={{ pathname: "/notes/[slug]/", query: { slug }, }} - passHref={true} - > - <Link dangerouslySetInnerHTML={{ __html: htmlTitle }} /> - </NextLink> + dangerouslySetInnerHTML={{ __html: htmlTitle }} + /> ); diff --git a/components/PageTitle/PageTitle.tsx b/components/PageTitle/PageTitle.tsx index a578c090..ac2c09f0 100644 --- a/components/PageTitle/PageTitle.tsx +++ b/components/PageTitle/PageTitle.tsx @@ -14,7 +14,7 @@ const Title = styled("h1", { }, }); -const Link = styled("a", { +const Link = styled(NextLink, { color: "$text", textDecoration: "none", }); @@ -26,9 +26,7 @@ const PageTitle = ({ children, ...rest }: PageTitleProps) => { return ( - <NextLink href={router.pathname} passHref={true}> - <Link>{children}</Link> - </NextLink> + <Link href={router.pathname}>{children}</Link> ); }; diff --git a/components/Selfie/Selfie.tsx b/components/Selfie/Selfie.tsx index f9a13f3b..221ec0ca 100644 --- a/components/Selfie/Selfie.tsx +++ b/components/Selfie/Selfie.tsx @@ -20,7 +20,7 @@ const Image = styled(NextImage, { }, }); -const Link = styled("a", { +const Link = styled(NextLink, { display: "inline-flex", alignItems: "center", color: "$mediumDark", @@ -48,15 +48,13 @@ const Name = styled("span", { }, }); -export type SelfieProps = ComponentProps; +export type SelfieProps = Omit, "href">; const Selfie = ({ ...rest }: SelfieProps) => ( - - - {`Photo - {authorName} - - + + {`Photo + {authorName} + ); export default Selfie; diff --git a/next.config.js b/next.config.js index 4bcf2ddb..8aa15d1b 100644 --- a/next.config.js +++ b/next.config.js @@ -43,6 +43,7 @@ module.exports = (phase, { defaultConfig }) => { // allow forgoing the mess of ``s around statically imported images layoutRaw: true, }, + newNextLinkBehavior: true, // https://github.com/vercel/next.js/pull/36436 }, webpack: (config) => { // this lets us statically import webfonts like we would images, allowing cool things like preloading them