feat: added not-found and error pages

This commit is contained in:
2023-01-10 01:22:49 +01:00
parent 4e417266c4
commit 478d986a7d
7 changed files with 95 additions and 44 deletions
+32
View File
@@ -0,0 +1,32 @@
import { Header } from '../components/Header'
function splitFirst(s: string, sep: string): string[] {
const i = s.indexOf(sep)
if (i === -1) {
return [s, '']
} else {
return [s.substring(0, i), s.substring(i + sep.length)]
}
}
const defaultErrorMessage = <>Purtroppo c'è stato un errore inaspettato</>
export const ErrorPage = ({ url }: { url: string }) => {
const query = Object.fromEntries(
splitFirst(url, '?')[1]
.split('&')
.map(kv => splitFirst(kv, '='))
.map(([k, v]) => [k, decodeURIComponent(v)])
)
return (
<>
<Header />
<main class="page-error">
<div class="title">Errore</div>
<p>{query.message.trim().length > 0 ? query.message : defaultErrorMessage}</p>
</main>
</>
)
}
+12
View File
@@ -0,0 +1,12 @@
import { Header } from '../components/Header'
export const NotFoundPage = ({}) => {
return (
<>
<Header />
<main class="page-not-found">
<div class="title">Pagina non trovata!</div>
</main>
</>
)
}