feat: expose config in context + simplify page props (#2102)

This commit is contained in:
Marvin Hagemeister
2023-11-30 16:11:31 +01:00
committed by GitHub
parent aafe048243
commit 9e11c5c56b
11 changed files with 254 additions and 123 deletions
+4
View File
@@ -18,6 +18,8 @@ import * as $api_head_override from "./routes/api/head_override.ts";
import * as $assetsCaching_index from "./routes/assetsCaching/index.tsx";
import * as $books_id_ from "./routes/books/[id].tsx";
import * as $connInfo from "./routes/connInfo.ts";
import * as $ctx_config from "./routes/ctx_config.tsx";
import * as $ctx_config_props from "./routes/ctx_config_props.tsx";
import * as $error_boundary from "./routes/error_boundary.tsx";
import * as $event_handler_string from "./routes/event_handler_string.tsx";
import * as $event_handler_string_island from "./routes/event_handler_string_island.tsx";
@@ -117,6 +119,8 @@ const manifest = {
"./routes/assetsCaching/index.tsx": $assetsCaching_index,
"./routes/books/[id].tsx": $books_id_,
"./routes/connInfo.ts": $connInfo,
"./routes/ctx_config.tsx": $ctx_config,
"./routes/ctx_config_props.tsx": $ctx_config_props,
"./routes/error_boundary.tsx": $error_boundary,
"./routes/event_handler_string.tsx": $event_handler_string,
"./routes/event_handler_string_island.tsx": $event_handler_string_island,
+19
View File
@@ -0,0 +1,19 @@
import { defineRoute } from "$fresh/server.ts";
import { relative, SEP } from "$fresh/tests/deps.ts";
export default defineRoute((_req, ctx) => {
const value = JSON.stringify(ctx, (key, value) => {
if (key === "outDir" || key == "staticDir") {
return relative(Deno.cwd(), value).split(SEP).join("/");
}
if (typeof value === "function") return value.constructor.name;
if (value === undefined) return "<undefined>";
return value;
}, 2);
return (
<pre>
{value}
</pre>
);
});
+15
View File
@@ -0,0 +1,15 @@
import { PageProps } from "$fresh/server.ts";
import { relative, SEP } from "../../deps.ts";
export default function Page(props: PageProps) {
const value = JSON.stringify(props, (key, value) => {
if (key === "outDir" || key == "staticDir") {
return relative(Deno.cwd(), value).split(SEP).join("/");
}
if (typeof value === "function") return value.constructor.name;
if (value === undefined) return "<undefined>";
return value;
}, 2);
return <pre>{value}</pre>;
}