@analogjs/vite-plugin-nitro
Version:
A Vite plugin for adding a nitro API server
37 lines (36 loc) • 1.51 kB
TypeScript
import { PrerenderRoute } from 'nitropack';
import { I18nPrerenderOptions } from '../options.js';
/**
* Expands a list of routes to include locale-prefixed variants.
*
* For each route and each locale, generates a prefixed route:
* '/' + locale + route
*
* The default locale's routes are included both with and without the prefix
* so that `/about` and `/en/about` both render.
*
* @param routes - The original routes to expand
* @param i18n - The i18n prerender configuration
* @returns Expanded routes with locale prefixes
*/
export declare function expandRoutesWithLocales(routes: string[], i18n: I18nPrerenderOptions): string[];
/**
* Creates a post-rendering hook that injects the `lang` attribute
* into the `<html>` tag of prerendered pages based on the route's
* locale prefix.
*
* @param i18n - The i18n prerender configuration
* @returns A post-rendering hook function
*/
export declare function createI18nPostRenderingHook(i18n: I18nPrerenderOptions): (route: PrerenderRoute) => Promise<void>;
/**
* Detects the locale from a prerendered route path by checking
* the first path segment against the configured locales.
*/
export declare function detectLocaleFromRoute(route: string, i18n: I18nPrerenderOptions): string;
/**
* Sets the `lang` attribute on the `<html>` tag in an HTML string.
* If a `lang` attribute already exists, it is replaced.
* If no `lang` attribute exists, it is added.
*/
export declare function setHtmlLang(html: string, locale: string): string;