Skip to content

Commit ca55a53

Browse files
committed
adding in doc routes
1 parent c51b67e commit ca55a53

File tree

10 files changed

+444
-185
lines changed

10 files changed

+444
-185
lines changed

app/root.jsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Outlet, Scripts } from "react-router";
1+
import { isRouteErrorResponse, Outlet, Scripts, useNavigate } from "react-router";
22
import { make as Navigation } from "../src/components/Navigation.mjs";
33
import "../styles/_hljs.css";
44
import "../styles/main.css";
@@ -25,6 +25,7 @@ hljs.registerLanguage('html', html)
2525
hljs.registerLanguage('diff', diff)
2626

2727

28+
2829
export default function App() {
2930
return (
3031
<html>
@@ -41,4 +42,31 @@ export default function App() {
4142
</body>
4243
</html>
4344
);
45+
}
46+
47+
export function ErrorBoundary({
48+
error,
49+
}) {
50+
const navigate = useNavigate()
51+
if (isRouteErrorResponse(error)) {
52+
return (
53+
<>
54+
<h1>
55+
{error.status} {error.statusText}
56+
</h1>
57+
<p>{error.data}</p>
58+
</>
59+
);
60+
} else if (error instanceof Error) {
61+
return (
62+
<div>
63+
<h1>Error</h1>
64+
<p>{error.message}</p>
65+
<p>The stack trace is:</p>
66+
<pre>{error.stack}</pre>
67+
</div>
68+
);
69+
} else {
70+
return <h1>Unknown Error</h1>;
71+
}
4472
}

app/routes.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ import { routes } from 'react-router-mdx/server';
33

44
export default [
55
index("./routes/LandingPageRoute.jsx"),
6-
...routes("./routes/mdx.jsx")
6+
...routes("./routes/mdx.jsx"),
77
]

app/routes/$.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export const loader = () => {
2+
console.log("Loading $ route");
3+
return {}
4+
}
5+
6+
export default function $Route() {
7+
return (
8+
<div>
9+
<h1>$ Route</h1>
10+
<p>This is a placeholder for the $ route.</p>
11+
</div>
12+
);
13+
}

0 commit comments

Comments
 (0)