@flow-os/router 0.0.51-dev.1772057566 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
export default function NotFound(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
export default function NotFound(params: Record<string, string>) {
|
|
2
|
+
const path = params['404'] ?? params.rest ?? '/';
|
|
3
|
+
return (
|
|
4
|
+
<div
|
|
5
|
+
role="alert"
|
|
6
|
+
style={{
|
|
7
|
+
minHeight: '100vh',
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flexDirection: 'column',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
justifyContent: 'center',
|
|
12
|
+
gap: '0.5rem',
|
|
13
|
+
}}
|
|
14
|
+
>
|
|
15
|
+
<h1 style={{ margin: 0, fontSize: '2rem' }}>404</h1>
|
|
16
|
+
<p style={{ margin: 0, color: 'var(--muted, #666)' }}>
|
|
17
|
+
{path && path !== '/' ? `Page not found: /${path}` : 'Page not found'}
|
|
18
|
+
</p>
|
|
19
|
+
<a href="/" style={{ marginTop: '1rem' }}>
|
|
20
|
+
Back to home
|
|
21
|
+
</a>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|
package/package.json
CHANGED
package/src/router/router.ts
CHANGED
|
@@ -38,29 +38,15 @@ export interface RouterAPI {
|
|
|
38
38
|
start(): void;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const NOT_FOUND_PATTERN = '404';
|
|
42
|
-
|
|
43
41
|
export function createRouter(
|
|
44
42
|
modules: Record<string, () => Promise<RouteModule>>,
|
|
45
43
|
container: HTMLElement,
|
|
46
44
|
options: RouterOptions = {}
|
|
47
45
|
): RouterAPI {
|
|
48
46
|
const allEntries = buildRouteEntries(modules);
|
|
49
|
-
const routes = allEntries
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const notFound: Node | ((path: string) => Node | Promise<Node>) =
|
|
53
|
-
options.notFound ??
|
|
54
|
-
(notFoundLoader
|
|
55
|
-
? (path) =>
|
|
56
|
-
notFoundLoader().then((mod) => {
|
|
57
|
-
const def = mod.default;
|
|
58
|
-
return typeof def === 'function' ? (def as (p: string) => Node)(path) : (def as unknown as Node);
|
|
59
|
-
})
|
|
60
|
-
: defaultNotFound);
|
|
61
|
-
const fullPageNotFound = Boolean(
|
|
62
|
-
options.appRoot && options.getLayout && (options.notFound != null || notFoundLoader != null)
|
|
63
|
-
);
|
|
47
|
+
const routes = allEntries;
|
|
48
|
+
const notFound: Node | ((path: string) => Node | Promise<Node>) = options.notFound ?? defaultNotFound;
|
|
49
|
+
const fullPageNotFound = Boolean(options.appRoot && options.getLayout && options.notFound != null);
|
|
64
50
|
|
|
65
51
|
function getContainer(): HTMLElement | null {
|
|
66
52
|
return document.getElementById(APP_ID);
|