diff --git a/app/library/language-switcher/LanguageSwitcher.tsx b/app/library/language-switcher/LanguageSwitcher.tsx index a13393ad1..85294f7dd 100644 --- a/app/library/language-switcher/LanguageSwitcher.tsx +++ b/app/library/language-switcher/LanguageSwitcher.tsx @@ -1,6 +1,7 @@ import { useTranslation } from "react-i18next" -import { Link, useLocation } from "react-router" +import { useLocation } from "react-router" import { supportedLanguages } from "~/localization/resource" +import { Link } from "../link" const LanguageSwitcher = () => { const { i18n } = useTranslation() @@ -11,7 +12,7 @@ const LanguageSwitcher = () => {
{supportedLanguages.map((language) => ( i18n.changeLanguage(language)} diff --git a/app/library/link/README.md b/app/library/link/README.md new file mode 100644 index 000000000..eedd96ac1 --- /dev/null +++ b/app/library/link/README.md @@ -0,0 +1,9 @@ +# Link + +This is a simple link component that wraps the `Link` component from `react-router` and provides view transitions and prefetching by default. + + +## Benefits + +- You prefetch other routes before the user clicks on the link. +- You get view transitions for free on every navigation. \ No newline at end of file diff --git a/app/library/link/index.ts b/app/library/link/index.ts new file mode 100644 index 000000000..6ada303c0 --- /dev/null +++ b/app/library/link/index.ts @@ -0,0 +1 @@ +export * from "./link" diff --git a/app/library/link/link.tsx b/app/library/link/link.tsx new file mode 100644 index 000000000..3d7db669d --- /dev/null +++ b/app/library/link/link.tsx @@ -0,0 +1,7 @@ +import { Link as ReactRouterLink, type LinkProps as ReactRouterLinkProps } from "react-router" + +interface LinkProps extends ReactRouterLinkProps {} + +export const Link = ({ prefetch = "intent", viewTransition = true, ...props }: LinkProps) => { + return +} diff --git a/app/root.tsx b/app/root.tsx index ca41d8405..12a011b31 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -59,11 +59,11 @@ export const ErrorBoundary = () => { const errorStatusCode = isRouteErrorResponse(error) ? error.status : "500" return ( -
+

{t(`error.${errorStatusCode}.title`)}

-

{t(`error.${errorStatusCode}.description`)}

+

{t(`error.${errorStatusCode}.description`)}

diff --git a/app/routes/$.tsx b/app/routes/$.tsx index 2440afb5f..27edda922 100644 --- a/app/routes/$.tsx +++ b/app/routes/$.tsx @@ -1,21 +1,22 @@ import { useTranslation } from "react-i18next" -import { Link, useNavigate } from "react-router" +import { useNavigate } from "react-router" import { Icon } from "~/library/icon/Icon" +import { Link } from "~/library/link" export default function Route404() { const navigate = useNavigate() const { t } = useTranslation() return ( -
+
-

404

-

{t("error.404.title")}

-

{t("error.404.description")}

+

404

+

{t("error.404.title")}

+

{t("error.404.description")}