diff --git a/app/components/doc-route.tsx b/app/components/doc-route.tsx index d7ea0f80..1cfc61f8 100644 --- a/app/components/doc-route.tsx +++ b/app/components/doc-route.tsx @@ -1,8 +1,4 @@ -import type { - DataFunctionArgs, - SerializeFrom, - MetaFunction, -} from "@remix-run/node"; +import type { LoaderArgs, MetaFunction, SerializeFrom } from "@remix-run/node"; import * as React from "react"; import { json, Response } from "@remix-run/node"; import { useLoaderData, useParams } from "@remix-run/react"; @@ -14,7 +10,7 @@ import { seo } from "~/seo"; import { useDelegatedReactRouterLinks } from "./delegate-markdown-links"; import iconsHref from "~/icons.svg"; -export let loader = async ({ params, request }: DataFunctionArgs) => { +export let loader = async ({ params, request }: LoaderArgs) => { await whyDoWeNotHaveGoodMiddleWareYetRyan(request); invariant(params.ref, "expected `ref` params"); diff --git a/app/modules/gh-docs/index.ts b/app/modules/gh-docs/index.ts index ff24a4df..e39736ed 100644 --- a/app/modules/gh-docs/index.ts +++ b/app/modules/gh-docs/index.ts @@ -6,7 +6,7 @@ import invariant from "tiny-invariant"; export { validateParams } from "./params"; export { getRepoTarballStream } from "./repo-tarball"; -export type { MenuDoc, Doc } from "./docs"; +export type { Doc } from "./docs"; const REPO = process.env.SOURCE_REPO!; if (!REPO) throw new Error("Missing process.env.SOURCE_REPO"); diff --git a/app/root.tsx b/app/root.tsx index c9379c08..1ae8c040 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -1,8 +1,4 @@ -import type { - LinksFunction, - LoaderFunction, - MetaFunction, -} from "@remix-run/node"; +import type { LinksFunction, LoaderArgs, MetaFunction } from "@remix-run/node"; import { Link, Links, @@ -28,7 +24,7 @@ export const links: LinksFunction = () => { return [{ rel: "stylesheet", href: tailwindStylesheetUrl }]; }; -export const meta: MetaFunction = ({ data }: { data: LoaderData }) => { +export const meta: MetaFunction = ({ data }) => { return { title: "React Router", robots: data.isProductionHost ? "index,follow" : "noindex, nofollow", @@ -36,18 +32,13 @@ export const meta: MetaFunction = ({ data }: { data: LoaderData }) => { }; }; -type LoaderData = { - colorScheme: "light" | "dark" | "system"; - isProductionHost: boolean; -}; - -export let loader: LoaderFunction = async ({ request }) => { +export let loader = async ({ request }: LoaderArgs) => { await whyDoWeNotHaveGoodMiddleWareYetRyan(request); let colorScheme = await parseColorScheme(request); let isProductionHost = isHost("reactrouter.com", request); - return json( + return json( { colorScheme, isProductionHost }, { headers: { diff --git a/app/routes/$.tsx b/app/routes/$.tsx index 39087190..5638e433 100644 --- a/app/routes/$.tsx +++ b/app/routes/$.tsx @@ -1,8 +1,8 @@ -import type { LoaderFunction } from "@remix-run/node"; +import type { LoaderArgs } from "@remix-run/node"; import { Link, useCatch } from "@remix-run/react"; import { whyDoWeNotHaveGoodMiddleWareYetRyan } from "~/http"; -export let loader: LoaderFunction = async ({ request }) => { +export let loader = async ({ request }: LoaderArgs) => { await whyDoWeNotHaveGoodMiddleWareYetRyan(request); throw new Response("Not Found", { status: 404 }); }; diff --git a/app/routes/$lang.$ref.tsx b/app/routes/$lang.$ref.tsx index 82299553..9e0b09ea 100644 --- a/app/routes/$lang.$ref.tsx +++ b/app/routes/$lang.$ref.tsx @@ -1,5 +1,5 @@ +import type { LoaderArgs } from "@remix-run/node"; import { json, redirect } from "@remix-run/node"; -import type { LoaderFunction } from "@remix-run/node"; import * as React from "react"; import { Form, @@ -24,24 +24,13 @@ import { getRepoTags, validateParams, } from "~/modules/gh-docs"; -import type { Doc, MenuDoc } from "~/modules/gh-docs"; +import type { Doc } from "~/modules/gh-docs"; import iconsHref from "~/icons.svg"; import { DetailsMenu } from "~/modules/details-menu"; import { getLatestVersion } from "~/modules/gh-docs/tags"; import { useColorScheme } from "~/modules/color-scheme/components"; -type LoaderData = { - menu?: MenuDoc[]; - versions: string[]; - latestVersion: string; - releaseBranch: string; - branches: string[]; - lang: string; - currentGitHubRef: string; - isLatest: boolean; -}; - -export let loader: LoaderFunction = async ({ params, request }) => { +export let loader = async ({ params }: LoaderArgs) => { let { lang, ref, "*": splat } = params; invariant(lang, "expected `params.lang`"); invariant(ref, "expected `params.ref`"); @@ -64,7 +53,7 @@ export let loader: LoaderFunction = async ({ params, request }) => { let latestVersion = getLatestVersion(tags); let isLatest = ref === releaseBranch || ref === latestVersion; - return json({ + return json({ menu, versions: [getLatestVersion(tags)], latestVersion, @@ -124,7 +113,7 @@ export default function DocsLayout() { } function VersionWarning() { - let { isLatest, branches, currentGitHubRef } = useLoaderData(); + let { isLatest, branches, currentGitHubRef } = useLoaderData(); if (isLatest) return null; @@ -373,7 +362,7 @@ function VersionSelect() { branches, currentGitHubRef, lang, - } = useLoaderData(); + } = useLoaderData(); // This is the same default, hover, focus style as the ColorScheme trigger const className = @@ -540,7 +529,7 @@ function MenuLink({ to, children }: { to: string; children: React.ReactNode }) { } function Menu() { - let { menu } = useLoaderData(); + let { menu } = useLoaderData(); return menu ? (