UNPKG

@inlang/paraglide-js

Version:

[![NPM Downloads](https://img.shields.io/npm/dw/%40inlang%2Fparaglide-js?logo=npm&logoColor=red&label=npm%20downloads)](https://www.npmjs.com/package/@inlang/paraglide-js) [![GitHub Issues](https://img.shields.io/github/issues-closed/opral/paraglide-js?lo

45 lines 1.91 kB
/** * Generates localized URL variants for all provided URLs based on your configured locales and URL patterns. * * This function is essential for Static Site Generation (SSG) where you need to tell your framework * which pages to pre-render at build time. It's also useful for generating sitemaps and * `<link rel="alternate" hreflang>` tags for SEO. * * The function respects your `urlPatterns` configuration - if you have translated pathnames * (e.g., `/about``/ueber-uns` for German), it will generate the correct localized paths. * * @see https://paraglidejs.com/static-site-generation * * @example * // Basic usage - generate all locale variants for a list of paths * const localizedUrls = generateStaticLocalizedUrls([ * "/", * "/about", * "/blog/post-1", * ]); * // Returns URL objects for each locale: * // ["/en/", "/de/", "/en/about", "/de/about", "/en/blog/post-1", "/de/blog/post-1"] * * @example * // Use with framework SSG APIs * // SvelteKit * export function entries() { * const paths = ["/", "/about", "/contact"]; * return generateStaticLocalizedUrls(paths).map(url => ({ * locale: extractLocaleFromUrl(url) * })); * } * * @example * // Sitemap generation * const allPages = ["/", "/about", "/blog"]; * const sitemapUrls = generateStaticLocalizedUrls(allPages); * * @param {(string | URL)[]} urls - List of canonical URLs or paths to generate localized versions for. * Can be absolute URLs (`https://example.com/about`) or paths (`/about`). * Paths are resolved against `http://localhost` internally. * @returns {URL[]} Array of URL objects representing all localized variants. * The order follows each input URL with all its locale variants before moving to the next URL. */ export declare function generateStaticLocalizedUrls(urls: (string | URL)[]): URL[]; //# sourceMappingURL=generate-static-localized-urls.d.ts.map