createGetI18nLinks() — astro Function Reference
Architecture documentation for the createGetI18nLinks() function in generate-sitemap.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD cacf4540_2298_2ff0_86d4_04db3e32abba["createGetI18nLinks()"] 4d468d9c_03e7_8c51_0595_3a29c64d320e["generate-sitemap.ts"] cacf4540_2298_2ff0_86d4_04db3e32abba -->|defined in| 4d468d9c_03e7_8c51_0595_3a29c64d320e 9dbe89e5_a8f4_3c74_45b9_38a2b2e87101["generateSitemap()"] 9dbe89e5_a8f4_3c74_45b9_38a2b2e87101 -->|calls| cacf4540_2298_2ff0_86d4_04db3e32abba style cacf4540_2298_2ff0_86d4_04db3e32abba fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/integrations/sitemap/src/generate-sitemap.ts lines 34–77
function createGetI18nLinks(
urls: string[],
defaultLocale: string,
locales: Record<string, string>,
finalSiteUrl: string,
): GetI18nLinks {
// `parsedI18nUrls` will have the same length as `urls`, matching correspondingly
const parsedI18nUrls = urls.map((url) => parseI18nUrl(url, defaultLocale, locales, finalSiteUrl));
// Cache as multiple i18n URLs with the same path will have the same links
const i18nPathToLinksCache = new Map<string, SitemapItem['links']>();
return (urlIndex) => {
const i18nUrl = parsedI18nUrls[urlIndex];
if (!i18nUrl) {
return undefined;
}
const cached = i18nPathToLinksCache.get(i18nUrl.path);
if (cached) {
return cached;
}
// Find all URLs with the same path (without the locale part), e.g. /en/foo and /es/foo
const links: NonNullable<SitemapItem['links']> = [];
for (let i = 0; i < parsedI18nUrls.length; i++) {
const parsed = parsedI18nUrls[i];
if (parsed?.path === i18nUrl.path) {
links.push({
url: urls[i],
lang: locales[parsed.locale],
});
}
}
// If 0 or 1 (which is itself), return undefined to not create any links.
// We also don't need to cache this as we know there's no other URLs that would've match this.
if (links.length <= 1) {
return undefined;
}
i18nPathToLinksCache.set(i18nUrl.path, links);
return links;
};
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does createGetI18nLinks() do?
createGetI18nLinks() is a function in the astro codebase, defined in packages/integrations/sitemap/src/generate-sitemap.ts.
Where is createGetI18nLinks() defined?
createGetI18nLinks() is defined in packages/integrations/sitemap/src/generate-sitemap.ts at line 34.
What calls createGetI18nLinks()?
createGetI18nLinks() is called by 1 function(s): generateSitemap.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free