Skip to content

Commit

Permalink
update error page of all examples
Browse files Browse the repository at this point in the history
  • Loading branch information
phonzammi committed Jun 22, 2024
1 parent 4f08a13 commit 84675f6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
37 changes: 20 additions & 17 deletions examples/basic/pages/_error/+Page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
export default function Page(props: { is404: boolean; errorInfo?: string }) {
if (props.is404) {
return (
<>
<h1>404 Page Not Found</h1>
<p>This page could not be found.</p>
<p>{props.errorInfo}</p>
</>
);
} else {
return (
<>
<h1>500 Internal Server Error</h1>
<p>Something went wrong.</p>
</>
);
}
import { Show } from "solid-js";
import { usePageContext } from "vike-solid/usePageContext";

export default function Page() {
const { is404 } = usePageContext()

return (
<Show
when={is404}
fallback={
<>
<h1>500 Internal Server Error</h1>
<p>Something went wrong.</p>
</>
}
>
<h1>404 Page Not Found</h1>
<p>This page could not be found.</p>
</Show>
);
}
37 changes: 20 additions & 17 deletions examples/ssr-spa/pages/_error/+Page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
export default function Page(props: { is404: boolean; errorInfo?: string }) {
if (props.is404) {
return (
<>
<h1>404 Page Not Found</h1>
<p>This page could not be found.</p>
<p>{props.errorInfo}</p>
</>
);
} else {
return (
<>
<h1>500 Internal Server Error</h1>
<p>Something went wrong.</p>
</>
);
}
import { Show } from "solid-js";
import { usePageContext } from "vike-solid/usePageContext";

export default function Page() {
const { is404 } = usePageContext()

return (
<Show
when={is404}
fallback={
<>
<h1>500 Internal Server Error</h1>
<p>Something went wrong.</p>
</>
}
>
<h1>404 Page Not Found</h1>
<p>This page could not be found.</p>
</Show>
);
}

0 comments on commit 84675f6

Please sign in to comment.