import type { Context, Hono } from "hono"; import type { SiteConfig } from "@aotter/mantle-spec"; import { type SeoMeta } from "@aotter/mantle-web"; import type { CloudflareMantleRuntime, MantleRuntimeRef } from "./bootRuntimeOnce.js"; /** * `mountPublicRoutes` — mounts the SDK-managed public surface on the * consumer's Hono app. Replaces ~140 lines of route-stitching every * starter would otherwise hand-roll. * * Routes (per `collectionRoutes` config): * * - `GET /` → 302 to `/{canonicalLocale}` (skipped if `homeRenderer` not set) * - `GET /{locale}` → `homeRenderer` (composed; cross-collection) * - `GET /{locale}/{segment}` → collection list * - `GET /{locale}/{segment}/{slug}` → entry HTML * - `GET /{locale}/{segment}/{slug}.md` → entry markdown mirror (AEO) * - `GET /{locale}/{segment}/{slug}?preview=1` → live render via `previewEntry` use case * - `GET /{locale}/llms.txt` → composed llms.txt * - `GET /llms.txt` → composed root llms.txt * - `GET /robots.txt` → crawl policy + sitemap pointer * - `GET /sitemap.xml` → composed sitemap * * Slug overrides intercept `(collection, slug)` pairs the consumer * wants to serve from a hand-rolled template (e.g. a contact form * page that needs `` injected) rather than a * rendered entry. Overrides take precedence over preview and the * standard renderer. * * Public responses are rendered from canonical D1 state and carry * `s-maxage` for Cloudflare's version-local Workers Cache. `liveDev` * switches entry/list responses to `private, no-store`. */ export interface CollectionRouteConfig { /** Schema name (e.g. `"post-translations"`). */ readonly collection: string; /** URL segment beneath `/{locale}/`. Empty string puts entries * directly under `/{locale}/{slug}` (rare; useful when a single * collection owns the whole locale tree). */ readonly segment: string; /** When true, expose `GET /{locale}/{segment}` for the collection * list. Default false (most starters use a hand-rolled list page). */ readonly listRoute?: boolean; /** When true, expose `GET /{locale}/{segment}/{slug}.md` for the * AEO markdown mirror. Default true. */ readonly markdownMirror?: boolean; /** Slug to collapse to `/{locale}` (no trailing segment + slug). * Used for the home page when it lives in a translations * collection. */ readonly homeSlug?: string; } export interface PublicContentContext { readonly runtime: CloudflareMantleRuntime; readonly site: SiteConfig; readonly locale: string; } export interface PublicRouteContext extends PublicContentContext { readonly c: Context; readonly seo: SeoMeta; } export interface SlugOverride { readonly collection: string; readonly slug: string; readonly render: (ctx: PublicRouteContext) => Promise; } export interface MountPublicRoutesOptions { readonly collectionRoutes: ReadonlyArray; /** Renderer for `/{locale}` — typically composes home page + * recent posts across collections. Optional; without it `/` and * `/{locale}` are not registered. */ readonly homeRenderer?: (ctx: PublicRouteContext) => Promise; /** Agent-readable home body for composed homes without one backing Entry. */ readonly homeMarkdown?: (ctx: PublicContentContext) => Promise; /** Renderer for the locale 404 fallback. Required — every miss * falls through here. */ readonly notFoundRenderer: (ctx: PublicRouteContext) => Promise; /** Per-(collection, slug) override taking precedence over standard rendering. */ readonly slugOverrides?: ReadonlyArray; /** Live-dev flag — disables public caching for entry / list HTML. */ readonly liveDev?: boolean; } export declare function mountPublicRoutes(app: Hono, ref: MantleRuntimeRef, options: MountPublicRoutesOptions): void; //# sourceMappingURL=mountPublicRoutes.d.ts.map