Skip to content

Commit f44ba5a

Browse files
committed
feat(dash): add error pages
1 parent 8078bc5 commit f44ba5a

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

apps/dashboard/src/layouts/Layout.astro

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ import "../styles/fonts.scss"
1515
<body>
1616
<nav>
1717
<span>@smc/dashboard</span>
18-
<!-- TODO: get commit hash -->
19-
<code>12345fa</code>
18+
<code
19+
>{
20+
process.env.CF_PAGES_COMMIT_SHA
21+
? (process.env.CF_PAGES_COMMIT_SHA as string).substring(0, 7)
22+
: "a1b2c3d"
23+
}</code
24+
>
2025
<ul>
2126
<li>
2227
<a href="/">home</a>

apps/dashboard/src/pages/404.astro

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
import Layout from "../layouts/Layout.astro"
3+
---
4+
5+
<Layout>
6+
<main>
7+
<h1>404</h1>
8+
<p>Page Not Found</p>
9+
</main>
10+
</Layout>
11+
12+
<style>
13+
main {
14+
text-align: center;
15+
}
16+
17+
h1 {
18+
font-size: 4em;
19+
}
20+
</style>

apps/dashboard/src/pages/500.astro

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
import Layout from "../layouts/Layout.astro"
3+
4+
interface Props {
5+
error: unknown
6+
}
7+
8+
const { error } = Astro.props
9+
---
10+
11+
<Layout>
12+
<main>
13+
<h1>500</h1>
14+
<p>{error instanceof Error ? error.message : "Unknown Error"}</p>
15+
</main>
16+
</Layout>
17+
18+
<style>
19+
main {
20+
text-align: center;
21+
}
22+
23+
h1 {
24+
font-size: 4em;
25+
}
26+
</style>

apps/dashboard/src/styles/global.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
}
44

55
body {
6+
display: flex;
7+
flex-direction: column;
68
margin: 0;
79
padding: 0;
810
font-family: "JetBrains Mono", monospace;
911
background: #1e1e2e;
1012
color: #cdd6f4;
13+
height: 100dvh;
1114
}
1215

1316
a {
@@ -46,9 +49,11 @@ nav {
4649
}
4750

4851
main {
52+
flex: 1 1 auto;
4953
padding: 0 2em;
5054
}
5155

5256
footer {
5357
padding: 2em;
58+
text-align: center;
5459
}

0 commit comments

Comments
 (0)