From 2b1180352866904ab8d35b5e3f99d91965f3c313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Sat, 17 Jun 2023 19:05:14 +0200 Subject: [PATCH] docs: Export missing Plugin types to fix broken links (#1319) --- docs/concepts/plugins.md | 2 +- src/server/mod.ts | 5 +++++ src/server/types.ts | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/concepts/plugins.md b/docs/concepts/plugins.md index 4ce4d7d6..28d1304c 100644 --- a/docs/concepts/plugins.md +++ b/docs/concepts/plugins.md @@ -109,7 +109,7 @@ asynchronously return its either from an `async/await` function or wrapped within a promise. The render hook is called with the -[`AsyncPluginRenderContext`](https://deno.land/x/fresh/server.ts?s=AsyncPluginRenderContext) +[`PluginAsyncRenderContext`](https://deno.land/x/fresh/server.ts?s=PluginAsyncRenderContext) object, which contains a `renderAsync()` method. This method must be invoked during the render hook to actually render the page. It is a terminal error to not call the `renderAsync()` method during the render hook. diff --git a/src/server/mod.ts b/src/server/mod.ts index 82a57988..4b8bcc4f 100644 --- a/src/server/mod.ts +++ b/src/server/mod.ts @@ -24,6 +24,11 @@ export type { MiddlewareHandlerContext, PageProps, Plugin, + PluginAsyncRenderContext, + PluginAsyncRenderFunction, + PluginRenderContext, + PluginRenderFunction, + PluginRenderFunctionResult, PluginRenderResult, PluginRenderScripts, PluginRenderStyleTag, diff --git a/src/server/types.ts b/src/server/types.ts index a3559136..fdcb8c39 100644 --- a/src/server/types.ts +++ b/src/server/types.ts @@ -197,6 +197,7 @@ export interface ErrorHandlerContext> render: () => Response | Promise; state: State; } + export type ErrorHandler = ( req: Request, ctx: ErrorHandlerContext, @@ -303,6 +304,7 @@ export interface Plugin { export interface PluginRenderContext { render: PluginRenderFunction; } + export interface PluginAsyncRenderContext { renderAsync: PluginAsyncRenderFunction; } @@ -335,6 +337,7 @@ export interface PluginRenderScripts { } export type PluginRenderFunction = () => PluginRenderFunctionResult; + export type PluginAsyncRenderFunction = () => | PluginRenderFunctionResult | Promise;