Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the framework picker for form #133

Merged
2 changes: 1 addition & 1 deletion app/routes/form.$version.docs.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const loader = async (context: LoaderFunctionArgs) => {
})
}

export const meta: MetaFunction = ({ data }) => {
export const meta: MetaFunction<typeof loader> = ({ data }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the type errors around the meta functions in the files I worked on. Most of the remaining errors of this kind are getting fixed in #135.

return seo({
title: `${data?.title} | TanStack Form Docs`,
description: data?.description,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/form.$version.docs.framework.$framework.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const loader = async (context: LoaderFunctionArgs) => {
})
}

export const meta: MetaFunction = ({ data }) => {
export const meta: MetaFunction<typeof loader> = ({ data }) => {
return seo({
title: `${data?.title} | TanStack Form Docs`,
description: data?.description,
Expand Down
12 changes: 8 additions & 4 deletions app/routes/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import { FaDiscord, FaGithub } from 'react-icons/fa'
import type { AvailableOptions } from '~/components/Select'
import { Scarf } from '~/components/Scarf'

//

export type FrameworkMenu = {
framework: string
menuItems: MenuItem[]
Expand Down Expand Up @@ -118,6 +116,7 @@ export const useReactFormDocsConfig = () => {
const match = matches[matches.length - 1]
const params = useParams()
const version = params.version!

const framework =
params.framework || localStorage.getItem('framework') || 'react'
const navigate = useNavigate()
Expand Down Expand Up @@ -147,7 +146,9 @@ export const useReactFormDocsConfig = () => {
...match.params,
framework: option.value,
})
navigate(url)
localStorage.setItem('framework', option.value)

navigate(url, { state: { framework } })
},
}
}, [config.frameworkMenus, framework, match, navigate])
Expand Down Expand Up @@ -193,7 +194,10 @@ export const useReactFormDocsConfig = () => {
return {
label: d.label,
children: [
...d.children.map((d) => ({ ...d, badge: 'core' })),
...d.children.map((d) => ({
...d,
badge: 'core',
})),
...(match?.children ?? []).map((d) => ({ ...d, badge: framework })),
],
}
Expand Down
2 changes: 1 addition & 1 deletion app/routes/store.$version.docs.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const loader = async (context: LoaderFunctionArgs) => {
})
}

export const meta: MetaFunction = ({ data }) => {
export const meta: MetaFunction<typeof loader> = ({ data }) => {
return seo({
title: `${data?.title} | TanStack Store Docs`,
description: data?.description,
Expand Down
2 changes: 1 addition & 1 deletion app/routes/store.$version.docs.framework.$framework.$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const loader = async (context: LoaderFunctionArgs) => {
})
}

export const meta: MetaFunction = ({ data }) => {
export const meta: MetaFunction<typeof loader> = ({ data }) => {
return seo({
title: `${data?.title} | TanStack Store Docs`,
description: data?.description,
Expand Down
9 changes: 6 additions & 3 deletions app/routes/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import angularLogo from '~/images/angular-logo.svg'
import { FaDiscord, FaGithub } from 'react-icons/fa'
import type { AvailableOptions } from '~/components/Select'

//

export type FrameworkMenu = {
framework: string
menuItems: MenuItem[]
Expand Down Expand Up @@ -146,6 +144,8 @@ export const useReactStoreDocsConfig = () => {
...match.params,
framework: option.value,
})
localStorage.setItem('framework', option.value)

navigate(url)
},
}
Expand Down Expand Up @@ -192,7 +192,10 @@ export const useReactStoreDocsConfig = () => {
return {
label: d.label,
children: [
...d.children.map((d) => ({ ...d, badge: 'core' })),
...d.children.map(({ ...d }) => ({
...d,
badge: 'core',
})),
...(match?.children ?? []).map((d) => ({ ...d, badge: framework })),
],
}
Expand Down
Loading