Started documenting code

This commit is contained in:
Kevin FEDYNA
2025-01-22 00:54:43 +01:00
parent 54f4a83590
commit 3ce1273455
9 changed files with 72 additions and 24 deletions
+20 -7
View File
@@ -1,8 +1,12 @@
import { JSX } from "preact";
import { Partial } from "$fresh/runtime.ts";
import { FreshContext, RouteConfig } from "$fresh/server.ts";
import { State } from "$root/routes/_middleware.ts";
import { Route, State } from "$root/defaults/interfaces.ts";
/**
* Gets the `RouteConfig` config object for partial pages.
* @returns The partials config object.
*/
export function getPartialsConfig(): RouteConfig {
return {
skipAppWrapper: true,
@@ -10,12 +14,21 @@ export function getPartialsConfig(): RouteConfig {
};
}
export function makePartials(
page: (
request: Request,
context: FreshContext<State>,
) => Promise<JSX.Element>,
) {
/**
* Partialize the given page for optimized rendering.
* @param page The partial `Route` object to partialize.
* @returns The partialized version of `page`.
* @example
* // Page defintion...
* async function Page(_request: Request, context: FreshContext<State>) {
* return <h2>My super page!</h2>;
* }
*
* // Partial code that should be at each file's end.
* export const config = getPartialsConfig();
* export default makePartials(Page);
*/
export function makePartials(page: Route) {
return async function WrappedElements(
request: Request,
context: FreshContext<State>,