diff --git a/.prettierignore b/.prettierignore index e9a58b47..23ade6e3 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ **/api +**/build **/public pnpm-lock.yaml diff --git a/app/components/Docs.tsx b/app/components/DocsLayout.tsx similarity index 99% rename from app/components/Docs.tsx rename to app/components/DocsLayout.tsx index 9a36611f..7ac9c716 100644 --- a/app/components/Docs.tsx +++ b/app/components/DocsLayout.tsx @@ -29,7 +29,7 @@ export type DocsConfig = { }[] } -export function Docs({ +export function DocsLayout({ colorFrom, colorTo, textColor, diff --git a/app/projects/form.tsx b/app/projects/form.tsx index 4b966e26..69b84253 100644 --- a/app/projects/form.tsx +++ b/app/projects/form.tsx @@ -75,7 +75,7 @@ export function getBranch(argVersion?: string) { return ['latest', latestVersion].includes(version) ? latestBranch : version } -export const useReactFormDocsConfig = (config: ConfigSchema) => { +export const useFormDocsConfig = (config: ConfigSchema) => { const matches = useMatches() const match = matches[matches.length - 1] const params = useParams() diff --git a/app/projects/store.tsx b/app/projects/store.tsx index 6dee6545..cf6e4900 100644 --- a/app/projects/store.tsx +++ b/app/projects/store.tsx @@ -75,7 +75,7 @@ export function getBranch(argVersion?: string) { return ['latest', latestVersion].includes(version) ? latestBranch : version } -export const useReactStoreDocsConfig = (config: ConfigSchema) => { +export const useStoreDocsConfig = (config: ConfigSchema) => { const matches = useMatches() const match = matches[matches.length - 1] const params = useParams() diff --git a/app/routes/form.$version.docs.$.tsx b/app/routes/form.$version.docs.$.tsx index 5925ba1b..103b0bea 100644 --- a/app/routes/form.$version.docs.$.tsx +++ b/app/routes/form.$version.docs.$.tsx @@ -8,12 +8,14 @@ import { Doc } from '~/components/Doc' export const loader = async (context: LoaderFunctionArgs) => { const { '*': docsPath, version } = context.params + const { url } = context.request return loadDocs({ repo, branch: getBranch(version), docPath: `docs/${docsPath}`, - redirectPath: context.request.url.replace(/\/docs.*/, ``), + currentPath: url, + redirectPath: url.replace(/\/docs.*/, '/docs/overview'), }) } diff --git a/app/routes/form.$version.docs.framework.$framework.$.tsx b/app/routes/form.$version.docs.framework.$framework.$.tsx index 8a627c4d..5a0cf6b8 100644 --- a/app/routes/form.$version.docs.framework.$framework.$.tsx +++ b/app/routes/form.$version.docs.framework.$framework.$.tsx @@ -8,12 +8,14 @@ import { loadDocs } from '~/utils/docs' export const loader = async (context: LoaderFunctionArgs) => { const { '*': docsPath, framework, version } = context.params + const { url } = context.request return loadDocs({ repo, branch: getBranch(version), docPath: `docs/framework/${framework}/${docsPath}`, - redirectPath: context.request.url.replace(/\/docs.*/, ``), + currentPath: url, + redirectPath: url.replace(/\/docs.*/, '/docs/overview'), }) } diff --git a/app/routes/form.$version.docs.framework.$framework._index.tsx b/app/routes/form.$version.docs.framework.$framework._index.tsx index 610cd8cc..6f686156 100644 --- a/app/routes/form.$version.docs.framework.$framework._index.tsx +++ b/app/routes/form.$version.docs.framework.$framework._index.tsx @@ -1,11 +1,6 @@ -export const loader = () => { - // When first path part after docs contain framework name, just redirect to overview - // if ( - // context.request.url.includes('/docs/react') || - // context.request.url.includes('/docs/solid') || - // context.request.url.includes('/docs/vue') || - // context.request.url.includes('/docs/svelte') - // ) { - // throw redirect(context.request.url + '/overview') - // } +import { redirect } from '@remix-run/node' +import type { LoaderFunctionArgs } from '@remix-run/node' + +export const loader = async (context: LoaderFunctionArgs) => { + throw redirect(context.request.url.replace(/\/docs.*/, '/docs/overview')) } diff --git a/app/routes/form.$version.docs.framework.$framework.examples.$.tsx b/app/routes/form.$version.docs.framework.$framework.examples.$.tsx index d499bb90..ca4613c3 100644 --- a/app/routes/form.$version.docs.framework.$framework.examples.$.tsx +++ b/app/routes/form.$version.docs.framework.$framework.examples.$.tsx @@ -9,28 +9,28 @@ import { capitalize, slugToTitle } from '~/utils/utils' import { FaExternalLinkAlt } from 'react-icons/fa' export const loader = async (context: LoaderFunctionArgs) => { - const { framework: kind, '*': name } = context.params + const { framework, '*': name } = context.params - return json({ kind, name }) + return json({ framework, name }) } export const meta: MetaFunction = ({ data }) => { return seo({ - title: `${capitalize(data.kind)} Form ${slugToTitle( + title: `${capitalize(data.framework)} Form ${slugToTitle( data.name )} Example | TanStack Form Docs`, description: `An example showing how to implement ${slugToTitle( data.name - )} in ${capitalize(data.kind)} Form`, + )} in ${capitalize(data.framework)} Form`, }) } export default function RouteExamples() { - const { kind, name } = useLoaderData() + const { framework, name } = useLoaderData() const { version } = useParams() const branch = getBranch(version) - const examplePath = branch === 'v3' ? name : [kind, name].join('/') + const examplePath = [framework, name].join('/') const [isDark, setIsDark] = React.useState(true) @@ -51,7 +51,7 @@ export default function RouteExamples() {
- {capitalize(kind)} Example: {slugToTitle(name)} + {capitalize(framework)} Example: {slugToTitle(name)}
{ - return seo({ - title: 'TanStack Form Docs | React Form, Solid Form, Vue Form', - }) -} - -export default function RouteFrameworkParam() { - return ( - <> - - {/* */} - - ) -} diff --git a/app/routes/form.$version.docs.tsx b/app/routes/form.$version.docs.tsx index c2f000b7..b2d0d1c8 100644 --- a/app/routes/form.$version.docs.tsx +++ b/app/routes/form.$version.docs.tsx @@ -1,19 +1,14 @@ import type { LoaderFunctionArgs } from '@remix-run/node' import { json } from '@remix-run/node' import { Outlet, useLoaderData } from '@remix-run/react' -import { Docs } from '~/components/Docs' -import { - createLogo, - getBranch, - repo, - useReactFormDocsConfig, -} from '~/projects/form' +import { DocsLayout } from '~/components/DocsLayout' +import { createLogo, getBranch, repo, useFormDocsConfig } from '~/projects/form' import { getTanstackDocsConfig } from '~/utils/config' export const loader = async (context: LoaderFunctionArgs) => { - const branch = getBranch(context.params.version) - const tanstackDocsConfig = await getTanstackDocsConfig(repo, branch) const { version } = context.params + const branch = getBranch(version) + const tanstackDocsConfig = await getTanstackDocsConfig(repo, branch) return json({ tanstackDocsConfig, @@ -23,21 +18,19 @@ export const loader = async (context: LoaderFunctionArgs) => { export default function Component() { const { version, tanstackDocsConfig } = useLoaderData() - let config = useReactFormDocsConfig(tanstackDocsConfig) + let config = useFormDocsConfig(tanstackDocsConfig) return ( - - + ) } diff --git a/app/routes/query.$version.docs.$framework.tsx b/app/routes/query.$version.docs.$framework.tsx index f64dffb2..b8d55e48 100644 --- a/app/routes/query.$version.docs.$framework.tsx +++ b/app/routes/query.$version.docs.$framework.tsx @@ -9,8 +9,8 @@ import { useNavigate, } from '@remix-run/react' import { seo } from '~/utils/seo' -import type { DocsConfig } from '~/components/Docs' -import { Docs } from '~/components/Docs' +import type { DocsConfig } from '~/components/DocsLayout' +import { DocsLayout } from '~/components/DocsLayout' import { QueryGGBanner } from '~/components/QueryGGBanner' import { availableVersions, @@ -29,9 +29,9 @@ import { generatePath } from '~/utils/utils' import { getTanstackDocsConfig, type MenuItem } from '~/utils/config' export const loader = async (context: LoaderFunctionArgs) => { - const branch = getBranch(context.params.version) - const tanstackDocsConfig = await getTanstackDocsConfig(repo, branch) const { version, framework } = context.params + const branch = getBranch(version) + const tanstackDocsConfig = await getTanstackDocsConfig(repo, branch) return json({ tanstackDocsConfig, @@ -177,16 +177,14 @@ export default function RouteFrameworkParam() { return ( <> - ) diff --git a/app/routes/ranger.v1.docs.examples.tsx b/app/routes/ranger.v1.docs.examples.tsx deleted file mode 100644 index 7bc8bc77..00000000 --- a/app/routes/ranger.v1.docs.examples.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { Outlet } from '@remix-run/react' - -export default function ExamplesRoute() { - return -} diff --git a/app/routes/ranger.v1.docs.tsx b/app/routes/ranger.v1.docs.tsx index 57aebe50..23293858 100644 --- a/app/routes/ranger.v1.docs.tsx +++ b/app/routes/ranger.v1.docs.tsx @@ -4,7 +4,7 @@ import { Link, json, useLoaderData } from '@remix-run/react' import type { MetaFunction } from '@remix-run/node' import { gradientText, repo, v1branch } from '~/projects/ranger' import { seo } from '~/utils/seo' -import { Docs } from '~/components/Docs' +import { DocsLayout } from '~/components/DocsLayout' import { getTanstackDocsConfig } from '~/utils/config' export const loader = async () => { @@ -72,14 +72,12 @@ export default function DocsRoute() { ) return ( - ) } diff --git a/app/routes/router.v1.docs.examples.tsx b/app/routes/router.v1.docs.examples.tsx deleted file mode 100644 index 7bc8bc77..00000000 --- a/app/routes/router.v1.docs.examples.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { Outlet } from '@remix-run/react' - -export default function ExamplesRoute() { - return -} diff --git a/app/routes/router.v1.docs.tsx b/app/routes/router.v1.docs.tsx index f719ca3e..171eed03 100644 --- a/app/routes/router.v1.docs.tsx +++ b/app/routes/router.v1.docs.tsx @@ -3,7 +3,7 @@ import { Link, json, useLoaderData } from '@remix-run/react' import type { LoaderFunction, MetaFunction } from '@remix-run/node' import { gradientText, repo, v1branch } from '~/projects/router' import { seo } from '~/utils/seo' -import { Docs } from '~/components/Docs' +import { DocsLayout } from '~/components/DocsLayout' import { getTanstackDocsConfig } from '~/utils/config' export const loader: LoaderFunction = async () => { @@ -67,14 +67,12 @@ export default function DocsRoute() { } return ( - ) } diff --git a/app/routes/store.$version.docs.$.tsx b/app/routes/store.$version.docs.$.tsx index d2554a5a..863dae12 100644 --- a/app/routes/store.$version.docs.$.tsx +++ b/app/routes/store.$version.docs.$.tsx @@ -8,12 +8,14 @@ import { Doc } from '~/components/Doc' export const loader = async (context: LoaderFunctionArgs) => { const { '*': docsPath, version } = context.params + const { url } = context.request return loadDocs({ repo, branch: getBranch(version), docPath: `docs/${docsPath}`, - redirectPath: context.request.url.replace(/\/docs.*/, ``), + currentPath: url, + redirectPath: url.replace(/\/docs.*/, '/docs/overview'), }) } diff --git a/app/routes/store.$version.docs.framework.$framework.$.tsx b/app/routes/store.$version.docs.framework.$framework.$.tsx index 7ab24dd1..aae05c43 100644 --- a/app/routes/store.$version.docs.framework.$framework.$.tsx +++ b/app/routes/store.$version.docs.framework.$framework.$.tsx @@ -8,12 +8,14 @@ import { loadDocs } from '~/utils/docs' export const loader = async (context: LoaderFunctionArgs) => { const { '*': docsPath, framework, version } = context.params + const { url } = context.request return loadDocs({ repo, branch: getBranch(version), docPath: `docs/framework/${framework}/${docsPath}`, - redirectPath: context.request.url.replace(/\/docs.*/, ``), + currentPath: url, + redirectPath: url.replace(/\/docs.*/, '/docs/overview'), }) } diff --git a/app/routes/store.$version.docs.framework.$framework._index.tsx b/app/routes/store.$version.docs.framework.$framework._index.tsx index 610cd8cc..6f686156 100644 --- a/app/routes/store.$version.docs.framework.$framework._index.tsx +++ b/app/routes/store.$version.docs.framework.$framework._index.tsx @@ -1,11 +1,6 @@ -export const loader = () => { - // When first path part after docs contain framework name, just redirect to overview - // if ( - // context.request.url.includes('/docs/react') || - // context.request.url.includes('/docs/solid') || - // context.request.url.includes('/docs/vue') || - // context.request.url.includes('/docs/svelte') - // ) { - // throw redirect(context.request.url + '/overview') - // } +import { redirect } from '@remix-run/node' +import type { LoaderFunctionArgs } from '@remix-run/node' + +export const loader = async (context: LoaderFunctionArgs) => { + throw redirect(context.request.url.replace(/\/docs.*/, '/docs/overview')) } diff --git a/app/routes/store.$version.docs.framework.$framework.examples.$.tsx b/app/routes/store.$version.docs.framework.$framework.examples.$.tsx index 3dfd4f73..9137304c 100644 --- a/app/routes/store.$version.docs.framework.$framework.examples.$.tsx +++ b/app/routes/store.$version.docs.framework.$framework.examples.$.tsx @@ -9,28 +9,28 @@ import { capitalize, slugToTitle } from '~/utils/utils' import { FaExternalLinkAlt } from 'react-icons/fa' export const loader = async (context: LoaderFunctionArgs) => { - const { framework: kind, '*': name } = context.params + const { framework, '*': name } = context.params - return json({ kind, name }) + return json({ framework, name }) } export const meta: MetaFunction = ({ data }) => { return seo({ - title: `${capitalize(data.kind)} Store ${slugToTitle( + title: `${capitalize(data.framework)} Store ${slugToTitle( data.name )} Example | TanStack Store Docs`, description: `An example showing how to implement ${slugToTitle( data.name - )} in ${capitalize(data.kind)} Store`, + )} in ${capitalize(data.framework)} Store`, }) } export default function RouteExamples() { - const { kind, name } = useLoaderData() + const { framework, name } = useLoaderData() const { version } = useParams() const branch = getBranch(version) - const examplePath = branch === 'v3' ? name : [kind, name].join('/') + const examplePath = [framework, name].join('/') const [isDark, setIsDark] = React.useState(true) @@ -51,7 +51,7 @@ export default function RouteExamples() {
- {capitalize(kind)} Example: {slugToTitle(name)} + {capitalize(framework)} Example: {slugToTitle(name)}