studiocms
Version:
Astro Native CMS for AstroDB. Built from the ground up by the Astro community.
30 lines (29 loc) • 1.44 kB
TypeScript
import { type RouteConfig } from '../frontend/routes.js';
/**
* Utility that integrates StudioCMS routes into Astro's configuration during setup.
*
* This function is registered as an Astro config setup utility and, when invoked,
* retrieves the configured routes from the StudioCMS route effect and injects
* each route into Astro via the provided `injectRoute` callback.
*
* The implementation:
* - Constructs a route effect using `getRoutes` and provides it with a live
* `StudioCMSRouteConfig` constructed from the passed `options`.
* - Executes the effect to obtain the resolved routes.
* - Calls `injectRoute` for each resolved route, allowing Astro to register them.
*
* @param params - The utility invocation parameters. Expected to include:
* - `injectRoute` (function): callback provided by Astro to register a route.
* @param options - A `RouteConfig` used to configure the StudioCMS route effect.
*
* @returns A promise that resolves when all routes have been injected.
*
* @remarks
* - This utility performs side effects (route injection) and may throw if the
* route effect fails or if `injectRoute` throws.
* - Designed to run during Astro's config setup lifecycle.
*
* @example
* // (Registered automatically via defineUtility('astro:config:setup'))
*/
export declare const routeHandler: import("astro-integration-kit").HookUtility<"astro:config:setup", [options: RouteConfig], Promise<void>>;