Skip to content

Commit dd2d3e3

Browse files
authored
add default redirect for /stats (#394)
1 parent 74bc835 commit dd2d3e3

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

app/routeTree.gen.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { Route as LoginImport } from './routes/login'
1717
import { Route as DashboardImport } from './routes/dashboard'
1818
import { Route as LibrariesRouteImport } from './routes/_libraries/route'
1919
import { Route as LibraryIdRouteImport } from './routes/$libraryId/route'
20+
import { Route as StatsIndexImport } from './routes/stats/index'
2021
import { Route as LibrariesIndexImport } from './routes/_libraries/index'
2122
import { Route as LibraryIdIndexImport } from './routes/$libraryId/index'
2223
import { Route as LibrariesTermsImport } from './routes/_libraries/terms'
@@ -85,6 +86,12 @@ const LibraryIdRouteRoute = LibraryIdRouteImport.update({
8586
getParentRoute: () => rootRoute,
8687
} as any)
8788

89+
const StatsIndexRoute = StatsIndexImport.update({
90+
id: '/stats/',
91+
path: '/stats/',
92+
getParentRoute: () => rootRoute,
93+
} as any)
94+
8895
const LibrariesIndexRoute = LibrariesIndexImport.update({
8996
id: '/',
9097
path: '/',
@@ -399,6 +406,13 @@ declare module '@tanstack/react-router' {
399406
preLoaderRoute: typeof LibrariesIndexImport
400407
parentRoute: typeof LibrariesRouteImport
401408
}
409+
'/stats/': {
410+
id: '/stats/'
411+
path: '/stats'
412+
fullPath: '/stats'
413+
preLoaderRoute: typeof StatsIndexImport
414+
parentRoute: typeof rootRoute
415+
}
402416
'/$libraryId/$version/docs': {
403417
id: '/$libraryId/$version/docs'
404418
path: '/docs'
@@ -671,6 +685,7 @@ export interface FileRoutesByFullPath {
671685
'/terms': typeof LibrariesTermsRoute
672686
'/$libraryId/': typeof LibraryIdIndexRoute
673687
'/': typeof LibrariesIndexRoute
688+
'/stats': typeof StatsIndexRoute
674689
'/$libraryId/$version/docs': typeof LibraryIdVersionDocsRouteWithChildren
675690
'/blog/$': typeof LibrariesBlogSplatRoute
676691
'/blog/': typeof LibrariesBlogIndexRoute
@@ -707,6 +722,7 @@ export interface FileRoutesByTo {
707722
'/terms': typeof LibrariesTermsRoute
708723
'/$libraryId': typeof LibraryIdIndexRoute
709724
'/': typeof LibrariesIndexRoute
725+
'/stats': typeof StatsIndexRoute
710726
'/blog/$': typeof LibrariesBlogSplatRoute
711727
'/blog': typeof LibrariesBlogIndexRoute
712728
'/stats/npm': typeof StatsNpmIndexRoute
@@ -746,6 +762,7 @@ export interface FileRoutesById {
746762
'/_libraries/terms': typeof LibrariesTermsRoute
747763
'/$libraryId/': typeof LibraryIdIndexRoute
748764
'/_libraries/': typeof LibrariesIndexRoute
765+
'/stats/': typeof StatsIndexRoute
749766
'/$libraryId/$version/docs': typeof LibraryIdVersionDocsRouteWithChildren
750767
'/_libraries/blog/$': typeof LibrariesBlogSplatRoute
751768
'/_libraries/blog/': typeof LibrariesBlogIndexRoute
@@ -787,6 +804,7 @@ export interface FileRouteTypes {
787804
| '/terms'
788805
| '/$libraryId/'
789806
| '/'
807+
| '/stats'
790808
| '/$libraryId/$version/docs'
791809
| '/blog/$'
792810
| '/blog/'
@@ -822,6 +840,7 @@ export interface FileRouteTypes {
822840
| '/terms'
823841
| '/$libraryId'
824842
| '/'
843+
| '/stats'
825844
| '/blog/$'
826845
| '/blog'
827846
| '/stats/npm'
@@ -859,6 +878,7 @@ export interface FileRouteTypes {
859878
| '/_libraries/terms'
860879
| '/$libraryId/'
861880
| '/_libraries/'
881+
| '/stats/'
862882
| '/$libraryId/$version/docs'
863883
| '/_libraries/blog/$'
864884
| '/_libraries/blog/'
@@ -889,6 +909,7 @@ export interface RootRouteChildren {
889909
LoginRoute: typeof LoginRoute
890910
MerchRoute: typeof MerchRoute
891911
SponsorsEmbedRoute: typeof SponsorsEmbedRoute
912+
StatsIndexRoute: typeof StatsIndexRoute
892913
StatsNpmIndexRoute: typeof StatsNpmIndexRoute
893914
}
894915

@@ -899,6 +920,7 @@ const rootRouteChildren: RootRouteChildren = {
899920
LoginRoute: LoginRoute,
900921
MerchRoute: MerchRoute,
901922
SponsorsEmbedRoute: SponsorsEmbedRoute,
923+
StatsIndexRoute: StatsIndexRoute,
902924
StatsNpmIndexRoute: StatsNpmIndexRoute,
903925
}
904926

@@ -918,6 +940,7 @@ export const routeTree = rootRoute
918940
"/login",
919941
"/merch",
920942
"/sponsors-embed",
943+
"/stats/",
921944
"/stats/npm/"
922945
]
923946
},
@@ -1010,6 +1033,9 @@ export const routeTree = rootRoute
10101033
"filePath": "_libraries/index.tsx",
10111034
"parent": "/_libraries"
10121035
},
1036+
"/stats/": {
1037+
"filePath": "stats/index.tsx"
1038+
},
10131039
"/$libraryId/$version/docs": {
10141040
"filePath": "$libraryId/$version.docs.tsx",
10151041
"parent": "/$libraryId/$version",

app/routes/stats/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createFileRoute, redirect } from '@tanstack/react-router'
2+
3+
export const Route = createFileRoute('/stats/')({
4+
beforeLoad: () => {
5+
throw redirect({ to: '/stats/npm' })
6+
},
7+
})

0 commit comments

Comments
 (0)