diff --git a/app/projects/router.tsx b/app/projects/router.tsx index 5de2d054..9561f86d 100644 --- a/app/projects/router.tsx +++ b/app/projects/router.tsx @@ -1,6 +1,75 @@ +import { Link } from '@remix-run/react' +import reactLogo from '~/images/react-logo.svg' +import { FaDiscord, FaGithub } from 'react-icons/fa/index' +import { useDocsConfig } from '~/utils/config' +import type { ConfigSchema, MenuItem } from '~/utils/config' + export const repo = 'tanstack/router' -export const v1branch = 'main' +export const latestBranch = 'main' +export const latestVersion = 'v1' +export const availableVersions = ['v1'] export const gradientText = 'inline-block text-transparent bg-clip-text bg-gradient-to-r from-lime-500 to-emerald-500' + +const frameworks = { + react: { label: 'React', logo: reactLogo, value: 'react' }, +} as const + +export type Framework = keyof typeof frameworks + +export const createLogo = (version?: string) => ( + <> + + TanStack + + + Router + + {version === 'latest' ? latestVersion : version} + + + +) + +export const localMenu: MenuItem = { + label: 'Menu', + children: [ + { + label: 'Home', + to: '..', + }, + { + label: ( +
+ GitHub +
+ ), + to: 'https://github.com/tanstack/router', + }, + { + label: ( +
+ Discord +
+ ), + to: 'https://tlinz.com/discord', + }, + ], +} + +export function getBranch(argVersion?: string) { + const version = argVersion || latestVersion + + return ['latest', latestVersion].includes(version) ? latestBranch : version +} + +export const useRouterDocsConfig = (config: ConfigSchema) => { + return useDocsConfig({ + config, + frameworks, + localMenu, + availableVersions, + }) +} diff --git a/app/routes/router.$.tsx b/app/routes/router.$.tsx index 5ca9fab7..10c22c08 100644 --- a/app/routes/router.$.tsx +++ b/app/routes/router.$.tsx @@ -4,7 +4,7 @@ import { redirect } from '@remix-run/node' export const loader: LoaderFunction = (context) => { handleRedirects(context) - return redirect('/router/v1') + return redirect('/router/latest') } function handleRedirects(context: Parameters[0]) { @@ -27,8 +27,7 @@ function handleRedirects(context: Parameters[0]) { reactLocationv2List.forEach((item) => { if (url.pathname.startsWith(`/router/react-location/${item.from}`)) { throw redirect( - `/router/v1/${item.to}?from=reactLocationV2&original=https://react-location-v2.tanstack.com/${item.from}`, - 301 + `/router/v1/${item.to}?from=reactLocationV2&original=https://react-location-v2.tanstack.com/${item.from}` ) } }) diff --git a/app/routes/router.v1._index.tsx b/app/routes/router.$version._index.tsx similarity index 97% rename from app/routes/router.v1._index.tsx rename to app/routes/router.$version._index.tsx index e6a24e15..cb2eb146 100644 --- a/app/routes/router.v1._index.tsx +++ b/app/routes/router.$version._index.tsx @@ -7,18 +7,19 @@ import { FaGithub, FaTshirt, } from 'react-icons/fa' -import { Link, useLoaderData } from '@remix-run/react' +import { Link, useLoaderData, useParams } from '@remix-run/react' import { json } from '@remix-run/node' import { TbHeartHandshake, TbZoomQuestion } from 'react-icons/tb' import { VscPreview } from 'react-icons/vsc' import { RiLightbulbFlashLine } from 'react-icons/ri' -import { gradientText, v1branch } from '~/projects/router' +import { gradientText, getBranch } from '~/projects/router' import { Carbon } from '~/components/Carbon' import { Footer } from '~/components/Footer' import SponsorPack from '~/components/SponsorPack' import { Logo } from '~/components/Logo' import { getSponsorsForSponsorPack } from '~/server/sponsors' import type { LoaderFunction } from '@remix-run/node' +import type { Framework } from '~/projects/router' const menu = [ { @@ -81,10 +82,9 @@ export const loader: LoaderFunction = async () => { export default function TanStackRouterRoute() { const { sponsors } = useLoaderData() - const [framework] = React.useState< - 'react' | 'preact' | 'svelte' | 'vue' | 'solid' - >('react') - + const { version } = useParams() + const branch = getBranch(version) + const [framework] = React.useState('react') const [isDark, setIsDark] = React.useState(true) React.useEffect(() => { @@ -338,7 +338,7 @@ export default function TanStackRouterRoute() {