feat: add context information to render function (#46)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import { h, PageProps } from "../../deps.ts";
|
||||
|
||||
export default function Home(props: PageProps) {
|
||||
return <div>{JSON.stringify(props)}</div>;
|
||||
}
|
||||
+12
-10
@@ -2,19 +2,21 @@
|
||||
// This file SHOULD be checked into source version control.
|
||||
// To update this file, run `fresh routes`.
|
||||
|
||||
import * as $0 from "./pages/api/name.ts";
|
||||
import * as $1 from "./pages/api/get_only.ts";
|
||||
import * as $2 from "./pages/static.tsx";
|
||||
import * as $3 from "./pages/[name].tsx";
|
||||
import * as $4 from "./pages/index.tsx";
|
||||
import * as $0 from "./pages/index.tsx";
|
||||
import * as $1 from "./pages/static.tsx";
|
||||
import * as $2 from "./pages/props/[id].tsx";
|
||||
import * as $3 from "./pages/api/get_only.ts";
|
||||
import * as $4 from "./pages/api/name.ts";
|
||||
import * as $5 from "./pages/[name].tsx";
|
||||
|
||||
const routes = {
|
||||
pages: {
|
||||
"./pages/api/name.ts": $0,
|
||||
"./pages/api/get_only.ts": $1,
|
||||
"./pages/static.tsx": $2,
|
||||
"./pages/[name].tsx": $3,
|
||||
"./pages/index.tsx": $4,
|
||||
"./pages/index.tsx": $0,
|
||||
"./pages/static.tsx": $1,
|
||||
"./pages/props/[id].tsx": $2,
|
||||
"./pages/api/get_only.ts": $3,
|
||||
"./pages/api/name.ts": $4,
|
||||
"./pages/[name].tsx": $5,
|
||||
},
|
||||
baseUrl: import.meta.url,
|
||||
};
|
||||
|
||||
+12
-1
@@ -17,13 +17,24 @@ Deno.test("/ page prerender", async () => {
|
||||
body,
|
||||
`<script id="__FRSH_PROPS" type="application/json">`,
|
||||
);
|
||||
assert(!body.includes(`"params"`));
|
||||
assertStringIncludes(
|
||||
body,
|
||||
`"data":[["home","Hello!"]]`,
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("/props/123 page prerender", async () => {
|
||||
const resp = await router(new Request("https://fresh.deno.dev/props/123"));
|
||||
assert(resp);
|
||||
assertEquals(resp.status, 200);
|
||||
assertEquals(resp.headers.get("content-type"), "text/html; charset=utf-8");
|
||||
const body = await resp.text();
|
||||
assertStringIncludes(
|
||||
body,
|
||||
`{"props":{"params":{"id":"123"},"url":"https://fresh.deno.dev/props/123","route":"/props/:id"}}`,
|
||||
);
|
||||
});
|
||||
|
||||
Deno.test("/[name] page prerender", async () => {
|
||||
const resp = await router(new Request("https://fresh.deno.dev/foo"));
|
||||
assert(resp);
|
||||
|
||||
Reference in New Issue
Block a user