alepha
Version:
Easy-to-use modern TypeScript framework for building many kind of applications.
91 lines • 2.98 kB
TypeScript
import { KIND, Primitive } from "alepha";
import { DateTimeProvider } from "alepha/datetime";
import { ServerRouterProvider } from "alepha/server";
//#region ../../src/react/sitemap/primitives/$sitemap.d.ts
/**
* Expose a `sitemap.xml` generated from the application's `$page` primitives.
*
* Registers a `GET /sitemap.xml` route that reads every registered page at
* request time and emits a standard XML sitemap. Marked `static` by default, so
* the build prerenders it to `dist/public/sitemap.xml` for static deployments —
* while SSR runtimes also serve it live.
*
* The hostname comes from `options.hostname`, falling back to `PUBLIC_URL`, then
* to `""` (relative URLs).
*
* @example
* ```ts
* import { $sitemap } from "alepha/react/sitemap";
*
* class AppRouter {
* sitemap = $sitemap();
* }
* ```
*/
declare const $sitemap: {
(options?: SitemapPrimitiveOptions): SitemapPrimitive;
[KIND]: typeof SitemapPrimitive;
};
interface SitemapPrimitiveOptions {
/**
* Absolute base URL used to build `<loc>` entries (e.g. "https://alepha.dev").
*
* Defaults to `PUBLIC_URL`, then to `""` (relative URLs).
*/
hostname?: string;
/**
* Route path the sitemap is served at.
*
* @default "/sitemap.xml"
*/
path?: string;
/**
* Prerender the sitemap to a static file at build time.
*
* @default true
*/
static?: boolean;
}
declare class SitemapPrimitive extends Primitive<SitemapPrimitiveOptions> {
protected readonly router: ServerRouterProvider;
protected readonly dateTime: DateTimeProvider;
protected onInit(): void;
/**
* Render the sitemap to its path and body. Used by the build to snapshot the
* sitemap to a static file.
*/
prerender(): {
path: string;
body: string;
};
/**
* Build the sitemap XML from the application's page primitives.
*/
protected buildSitemap(): string;
/**
* Select the pages that should appear in the sitemap.
*
* Excludes layout pages (with `children`), wildcard paths, and `/404`.
* Parameterized pages are included only when they declare `static.entries`.
*/
protected getSitemapPages(): any[];
protected generateSitemapFromPages(pages: any[], baseUrl: string): string;
protected buildPathFromParams(pathPattern: string, params: Record<string, any>): string;
protected buildSitemapXml(urls: string[]): string;
protected escapeXml(str: string): string;
}
//#endregion
//#region ../../src/react/sitemap/index.d.ts
/**
* Sitemap generation for React applications.
*
* Exposes the {@link $sitemap} primitive, which serves a `sitemap.xml` built
* from the app's `$page` primitives — live at request time and prerendered to a
* static file at build time.
*
* @module alepha.react.sitemap
*/
declare const AlephaReactSitemap: import("alepha").Service<import("alepha").Module>;
//#endregion
export { $sitemap, AlephaReactSitemap, SitemapPrimitive, SitemapPrimitiveOptions };
//# sourceMappingURL=index.d.ts.map