-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a7842c
commit 117f783
Showing
5 changed files
with
47 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,42 @@ | ||
import { redirect, type LoaderFunctionArgs } from '@remix-run/node' | ||
import type { LoaderFunctionArgs, MetaFunction } from '@remix-run/node' | ||
import { repo, getBranch } from '~/routes/store' | ||
import { DefaultErrorBoundary } from '~/components/DefaultErrorBoundary' | ||
import { seo } from '~/utils/seo' | ||
import { useLoaderData, useParams } from '@remix-run/react' | ||
import { loadDocs } from '~/utils/docs' | ||
import { Doc } from '~/components/Doc' | ||
|
||
export const loader = async (context: LoaderFunctionArgs) => { | ||
const { '*': docsPath } = context.params | ||
const { '*': docsPath, version } = context.params | ||
|
||
throw redirect( | ||
// By default we'll redirect to the React docs | ||
context.request.url.replace(/\/docs.*/, `/docs/framework/react/${docsPath}`) | ||
return loadDocs({ | ||
repo, | ||
branch: getBranch(version), | ||
docPath: `docs/${docsPath}`, | ||
redirectPath: context.request.url.replace(/\/docs.*/, ``), | ||
}) | ||
} | ||
|
||
export const meta: MetaFunction<typeof loader> = ({ data }) => { | ||
return seo({ | ||
title: `${data?.title} | TanStack Store Docs`, | ||
description: data?.description, | ||
}) | ||
} | ||
|
||
export const ErrorBoundary = DefaultErrorBoundary | ||
|
||
export default function RouteDocs() { | ||
const { title, code, filePath } = useLoaderData<typeof loader>() | ||
const { version } = useParams() | ||
const branch = getBranch(version) | ||
return ( | ||
<Doc | ||
title={title} | ||
code={code} | ||
repo={repo} | ||
branch={branch} | ||
filePath={filePath} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters