mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 09:19:19 +00:00
18 lines
657 B
TypeScript
18 lines
657 B
TypeScript
|
|
import { GENEROUTED_ROOT, ROUTES_ROOT } from "@/routing/constants";
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Generouted's `generateRegularRoutes` / `generatePreservedRoutes` strip `/src/pages/`
|
||
|
|
* when building URL segments. Our views live under `/src/app/` (architecture convention),
|
||
|
|
* so we remap glob keys before passing them to the core.
|
||
|
|
*
|
||
|
|
* Ref: https://github.com/oedotme/generouted/tree/main/examples/react-router-custom-path
|
||
|
|
*/
|
||
|
|
export function remapAppToPages<T>(files: Record<string, T>): Record<string, T> {
|
||
|
|
return Object.fromEntries(
|
||
|
|
Object.entries(files).map(([key, value]) => [
|
||
|
|
key.replace(`${ROUTES_ROOT}/`, `${GENEROUTED_ROOT}/`),
|
||
|
|
value,
|
||
|
|
]),
|
||
|
|
);
|
||
|
|
}
|