Skip to content

Commit 7e0d447

Browse files
committed
fix: replace _services with app in iframe router
1 parent 4e324da commit 7e0d447

8 files changed

Lines changed: 34 additions & 36 deletions

File tree

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ NITRO_PUBLIC_TOLGEE_API_URL=https://j26-tolgee.nihlen.dev
44
NITRO_PUBLIC_TOLGEE_API_KEY=<replace-with-your-personal-access-token>
55
NITRO_PUBLIC_TOLGEE_PROJECT_ID=2
66

7-
NITRO_PUBLIC_APP_CONFIGS=/app-config.json,/dummy-page/app-config.json,/another-config.json
7+
NITRO_PUBLIC_APP_CONFIGS=/app-config.json,/another-config.json,/_services/booking/api/app-config.json
88
NITRO_PUBLIC_BOTTOM_NAV_ITEMS=page_my_schedule,page_all_activities,page_map,page_more

public/dummy-page/app-config.json renamed to public/_services/booking/api/app-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
"id": "page_all_activities",
1111
"label": "booking.all_activities.label",
1212
"icon": "campfire",
13-
"path": "./activities.html"
13+
"path": "../activities.html"
1414
},
1515
{
1616
"type": "page",
1717
"id": "page_my_schedule",
1818
"label": "booking.my_schedule.label",
1919
"icon": "calendar-event",
20-
"path": "./my.html"
20+
"path": "../my.html"
2121
}
2222
]
2323
}

src/components/microfrontends/IframeRouter.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { useNavigate } from "@tanstack/react-router";
22
import type { SyntheticEvent } from "react";
33

44
export type Props = {
5+
route: string;
56
baseUrl: string;
67
path: string;
78
name: string;
89
};
910

10-
export function IframeRouter({ baseUrl, path, name }: Props) {
11+
export function IframeRouter({ route, baseUrl, path, name }: Props) {
1112
const navigate = useNavigate();
1213

1314
const url = new URL(path, new URL(baseUrl, window.location.href)).toString();
@@ -25,7 +26,7 @@ export function IframeRouter({ baseUrl, path, name }: Props) {
2526
);
2627

2728
navigate({
28-
to: "/schedule/$",
29+
to: route,
2930
params: {
3031
_splat: relativePath,
3132
},

src/dynamic-routes/dynamic-routes.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ function remapPageUrl(page: Page, configUrl: string) {
1111
const absoluteConfigUrl = new URL(configUrl, window.location.href);
1212
const newUrl = new URL(page.path, absoluteConfigUrl);
1313

14-
const urlWithoutDomain = newUrl.pathname + newUrl.search + newUrl.hash;
14+
let urlWithoutDomain = newUrl.pathname + newUrl.search + newUrl.hash;
15+
16+
urlWithoutDomain = urlWithoutDomain.replace(/^\/_services\//, "/app/");
1517

1618
return {
1719
...page,

src/routeTree.gen.ts

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { Route as MoreRouteImport } from './routes/more'
1313
import { Route as AboutRouteImport } from './routes/about'
1414
import { Route as IndexRouteImport } from './routes/index'
1515
import { Route as MoreIndexRouteImport } from './routes/more.index'
16-
import { Route as ScheduleSplatRouteImport } from './routes/schedule.$'
1716
import { Route as MoreLanguageRouteImport } from './routes/more.language'
17+
import { Route as AppSplatRouteImport } from './routes/app.$'
1818

1919
const MoreRoute = MoreRouteImport.update({
2020
id: '/more',
@@ -36,67 +36,61 @@ const MoreIndexRoute = MoreIndexRouteImport.update({
3636
path: '/',
3737
getParentRoute: () => MoreRoute,
3838
} as any)
39-
const ScheduleSplatRoute = ScheduleSplatRouteImport.update({
40-
id: '/schedule/$',
41-
path: '/schedule/$',
42-
getParentRoute: () => rootRouteImport,
43-
} as any)
4439
const MoreLanguageRoute = MoreLanguageRouteImport.update({
4540
id: '/language',
4641
path: '/language',
4742
getParentRoute: () => MoreRoute,
4843
} as any)
44+
const AppSplatRoute = AppSplatRouteImport.update({
45+
id: '/app/$',
46+
path: '/app/$',
47+
getParentRoute: () => rootRouteImport,
48+
} as any)
4949

5050
export interface FileRoutesByFullPath {
5151
'/': typeof IndexRoute
5252
'/about': typeof AboutRoute
5353
'/more': typeof MoreRouteWithChildren
54+
'/app/$': typeof AppSplatRoute
5455
'/more/language': typeof MoreLanguageRoute
55-
'/schedule/$': typeof ScheduleSplatRoute
5656
'/more/': typeof MoreIndexRoute
5757
}
5858
export interface FileRoutesByTo {
5959
'/': typeof IndexRoute
6060
'/about': typeof AboutRoute
61+
'/app/$': typeof AppSplatRoute
6162
'/more/language': typeof MoreLanguageRoute
62-
'/schedule/$': typeof ScheduleSplatRoute
6363
'/more': typeof MoreIndexRoute
6464
}
6565
export interface FileRoutesById {
6666
__root__: typeof rootRouteImport
6767
'/': typeof IndexRoute
6868
'/about': typeof AboutRoute
6969
'/more': typeof MoreRouteWithChildren
70+
'/app/$': typeof AppSplatRoute
7071
'/more/language': typeof MoreLanguageRoute
71-
'/schedule/$': typeof ScheduleSplatRoute
7272
'/more/': typeof MoreIndexRoute
7373
}
7474
export interface FileRouteTypes {
7575
fileRoutesByFullPath: FileRoutesByFullPath
76-
fullPaths:
77-
| '/'
78-
| '/about'
79-
| '/more'
80-
| '/more/language'
81-
| '/schedule/$'
82-
| '/more/'
76+
fullPaths: '/' | '/about' | '/more' | '/app/$' | '/more/language' | '/more/'
8377
fileRoutesByTo: FileRoutesByTo
84-
to: '/' | '/about' | '/more/language' | '/schedule/$' | '/more'
78+
to: '/' | '/about' | '/app/$' | '/more/language' | '/more'
8579
id:
8680
| '__root__'
8781
| '/'
8882
| '/about'
8983
| '/more'
84+
| '/app/$'
9085
| '/more/language'
91-
| '/schedule/$'
9286
| '/more/'
9387
fileRoutesById: FileRoutesById
9488
}
9589
export interface RootRouteChildren {
9690
IndexRoute: typeof IndexRoute
9791
AboutRoute: typeof AboutRoute
9892
MoreRoute: typeof MoreRouteWithChildren
99-
ScheduleSplatRoute: typeof ScheduleSplatRoute
93+
AppSplatRoute: typeof AppSplatRoute
10094
}
10195

10296
declare module '@tanstack/react-router' {
@@ -129,20 +123,20 @@ declare module '@tanstack/react-router' {
129123
preLoaderRoute: typeof MoreIndexRouteImport
130124
parentRoute: typeof MoreRoute
131125
}
132-
'/schedule/$': {
133-
id: '/schedule/$'
134-
path: '/schedule/$'
135-
fullPath: '/schedule/$'
136-
preLoaderRoute: typeof ScheduleSplatRouteImport
137-
parentRoute: typeof rootRouteImport
138-
}
139126
'/more/language': {
140127
id: '/more/language'
141128
path: '/language'
142129
fullPath: '/more/language'
143130
preLoaderRoute: typeof MoreLanguageRouteImport
144131
parentRoute: typeof MoreRoute
145132
}
133+
'/app/$': {
134+
id: '/app/$'
135+
path: '/app/$'
136+
fullPath: '/app/$'
137+
preLoaderRoute: typeof AppSplatRouteImport
138+
parentRoute: typeof rootRouteImport
139+
}
146140
}
147141
}
148142

@@ -162,7 +156,7 @@ const rootRouteChildren: RootRouteChildren = {
162156
IndexRoute: IndexRoute,
163157
AboutRoute: AboutRoute,
164158
MoreRoute: MoreRouteWithChildren,
165-
ScheduleSplatRoute: ScheduleSplatRoute,
159+
AppSplatRoute: AppSplatRoute,
166160
}
167161
export const routeTree = rootRouteImport
168162
._addFileChildren(rootRouteChildren)
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createFileRoute } from "@tanstack/react-router";
22
import { IframeRouter } from "../components/microfrontends/IframeRouter";
33

4-
export const Route = createFileRoute("/schedule/$")({
4+
export const Route = createFileRoute("/app/$")({
55
component: RouteComponent,
66
});
77

@@ -10,9 +10,10 @@ function RouteComponent() {
1010

1111
return (
1212
<IframeRouter
13-
baseUrl="/dummy-page/"
13+
route="/app/$"
14+
baseUrl="/_services/"
1415
path={`./${path ?? ""}`}
15-
name="Schedule"
16+
name="REPLACE ME LOL"
1617
/>
1718
);
1819
}

0 commit comments

Comments
 (0)