feat: Allow passing props to renderNotFound method (#1310)
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { UnknownPageProps } from "$fresh/server.ts";
|
||||
|
||||
export default function NotFoundPage({ url }: UnknownPageProps) {
|
||||
return <p>404 not found: {url.pathname}</p>;
|
||||
export default function NotFoundPage({ data, url }: UnknownPageProps) {
|
||||
return (
|
||||
<>
|
||||
<p>404 not found: {url.pathname}</p>
|
||||
{data?.hello && <p>Hello {data.hello}</p>}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Handlers } from "../../../server.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
GET(_req, ctx) {
|
||||
return ctx.renderNotFound();
|
||||
return ctx.renderNotFound({
|
||||
hello: "Dino",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
@@ -565,6 +565,7 @@ Deno.test({
|
||||
assertEquals(resp.status, 404);
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(body, "404 not found: /not_found");
|
||||
assertStringIncludes(body, "Hello Dino");
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user