feat(server): add isPartial to context types (#1977)

This commit is contained in:
Reed von Redwitz
2023-10-26 22:26:36 +02:00
committed by GitHub
parent 7ad4610e3a
commit 63ac1e6362
13 changed files with 333 additions and 121 deletions
@@ -0,0 +1,32 @@
import { Handlers, PageProps, RouteConfig } from "$fresh/server.ts";
import { IsPartialInContextState } from "./_middleware.ts";
import { Partial } from "$fresh/runtime.ts";
export const config: RouteConfig = {
skipAppWrapper: true,
skipInheritedLayouts: true,
};
export const handler: Handlers = {
GET(_req, ctx) {
return ctx.render(ctx.isPartial);
},
};
export default function Home(
props: PageProps<boolean, IsPartialInContextState>,
) {
const result = {
isPartial: props.data,
setFromMiddleware: props.state.setFromMiddleware,
notSetFromMiddleware: props.state.notSetFromMiddleware,
};
if (props.data) {
return (
<Partial name="slot-1">
<pre>{JSON.stringify(result, null, 2)}</pre>
</Partial>
);
}
return <pre>{JSON.stringify(result, null, 2)}</pre>;
}