Skip to content

Commit 2c66d4c

Browse files
authored
fix sanity studio url (#1550)
Tanstack Start is a little weird when it comes to catch-all routes? 🤔 /studio/ does not work because the catch-all/splat route checks if there is anything AFTER studio/ and not including studio/, so it works when going to /studio/structure but not /studio/ So we create a new route that specifically targets /studio/ as well
1 parent 6dc3cf2 commit 2c66d4c

File tree

4 files changed

+186
-145
lines changed

4 files changed

+186
-145
lines changed

apps/docs/src/routeTree.gen.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import { Route as rootRouteImport } from './routes/__root'
1212
import { Route as DocsRouteImport } from './routes/_docs'
13+
import { Route as StudioIndexRouteImport } from './routes/studio/index'
1314
import { Route as DocsIndexRouteImport } from './routes/_docs/index'
1415
import { Route as StudioSplatRouteImport } from './routes/studio/$'
1516
import { Route as ApiHealthRouteImport } from './routes/api/health'
@@ -24,6 +25,11 @@ const DocsRoute = DocsRouteImport.update({
2425
id: '/_docs',
2526
getParentRoute: () => rootRouteImport,
2627
} as any)
28+
const StudioIndexRoute = StudioIndexRouteImport.update({
29+
id: '/studio/',
30+
path: '/studio/',
31+
getParentRoute: () => rootRouteImport,
32+
} as any)
2733
const DocsIndexRoute = DocsIndexRouteImport.update({
2834
id: '/',
2935
path: '/',
@@ -75,6 +81,7 @@ export interface FileRoutesByFullPath {
7581
'/api/health': typeof ApiHealthRoute
7682
'/studio/$': typeof StudioSplatRoute
7783
'/': typeof DocsIndexRoute
84+
'/studio': typeof StudioIndexRoute
7885
'/komponenter/$slug': typeof DocsKomponenterSlugRoute
7986
'/profil/farger': typeof DocsProfilFargerRoute
8087
'/profil/ikoner': typeof DocsProfilIkonerRoute
@@ -86,6 +93,7 @@ export interface FileRoutesByTo {
8693
'/api/health': typeof ApiHealthRoute
8794
'/studio/$': typeof StudioSplatRoute
8895
'/': typeof DocsIndexRoute
96+
'/studio': typeof StudioIndexRoute
8997
'/komponenter/$slug': typeof DocsKomponenterSlugRoute
9098
'/profil/farger': typeof DocsProfilFargerRoute
9199
'/profil/ikoner': typeof DocsProfilIkonerRoute
@@ -99,6 +107,7 @@ export interface FileRoutesById {
99107
'/api/health': typeof ApiHealthRoute
100108
'/studio/$': typeof StudioSplatRoute
101109
'/_docs/': typeof DocsIndexRoute
110+
'/studio/': typeof StudioIndexRoute
102111
'/_docs/komponenter/$slug': typeof DocsKomponenterSlugRoute
103112
'/_docs/profil/farger': typeof DocsProfilFargerRoute
104113
'/_docs/profil/ikoner': typeof DocsProfilIkonerRoute
@@ -112,6 +121,7 @@ export interface FileRouteTypes {
112121
| '/api/health'
113122
| '/studio/$'
114123
| '/'
124+
| '/studio'
115125
| '/komponenter/$slug'
116126
| '/profil/farger'
117127
| '/profil/ikoner'
@@ -123,6 +133,7 @@ export interface FileRouteTypes {
123133
| '/api/health'
124134
| '/studio/$'
125135
| '/'
136+
| '/studio'
126137
| '/komponenter/$slug'
127138
| '/profil/farger'
128139
| '/profil/ikoner'
@@ -135,6 +146,7 @@ export interface FileRouteTypes {
135146
| '/api/health'
136147
| '/studio/$'
137148
| '/_docs/'
149+
| '/studio/'
138150
| '/_docs/komponenter/$slug'
139151
| '/_docs/profil/farger'
140152
| '/_docs/profil/ikoner'
@@ -146,6 +158,7 @@ export interface RootRouteChildren {
146158
DocsRoute: typeof DocsRouteWithChildren
147159
ApiHealthRoute: typeof ApiHealthRoute
148160
StudioSplatRoute: typeof StudioSplatRoute
161+
StudioIndexRoute: typeof StudioIndexRoute
149162
}
150163

151164
declare module '@tanstack/react-router' {
@@ -157,6 +170,13 @@ declare module '@tanstack/react-router' {
157170
preLoaderRoute: typeof DocsRouteImport
158171
parentRoute: typeof rootRouteImport
159172
}
173+
'/studio/': {
174+
id: '/studio/'
175+
path: '/studio'
176+
fullPath: '/studio'
177+
preLoaderRoute: typeof StudioIndexRouteImport
178+
parentRoute: typeof rootRouteImport
179+
}
160180
'/_docs/': {
161181
id: '/_docs/'
162182
path: '/'
@@ -249,6 +269,7 @@ const rootRouteChildren: RootRouteChildren = {
249269
DocsRoute: DocsRouteWithChildren,
250270
ApiHealthRoute: ApiHealthRoute,
251271
StudioSplatRoute: StudioSplatRoute,
272+
StudioIndexRoute: StudioIndexRoute,
252273
}
253274
export const routeTree = rootRouteImport
254275
._addFileChildren(rootRouteChildren)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// See https://www.sanity.io/docs/embedding-sanity-studio
2+
3+
import { createFileRoute } from '@tanstack/react-router';
4+
import { Studio } from 'sanity';
5+
import sanityConfig from 'sanity.config';
6+
import cssLink from '@/styles/sanity.css?url';
7+
8+
export const Route = createFileRoute('/studio/')({
9+
head: () => ({
10+
links: [{ rel: 'stylesheet', href: cssLink }],
11+
}),
12+
component: () => <Studio config={sanityConfig} />,
13+
// Disable SSR for this route, as the studio is not meant to be rendered on the server
14+
ssr: false,
15+
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"@storybook/test-runner": "0.24.1",
3131
"@tailwindcss/vite": "4.1.17",
3232
"@types/bun": "1.3.2",
33-
"@types/react": "19.2.2",
34-
"@types/react-dom": "19.2.2",
33+
"@types/react": "19.2.7",
34+
"@types/react-dom": "19.2.3",
3535
"bunchee": "6.6.2",
3636
"fontaine": "0.7.0",
3737
"http-server": "14.1.1",

0 commit comments

Comments
 (0)