feat: expose config in context + simplify page props (#2102)
This commit is contained in:
@@ -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>
|
||||
);
|
||||
});
|
||||
@@ -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>;
|
||||
}
|
||||
Reference in New Issue
Block a user