Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new api generateStaticLocalizedUrls() #433

Open
samuelstroschein opened this issue Mar 3, 2025 · 1 comment
Open

new api generateStaticLocalizedUrls() #433

samuelstroschein opened this issue Mar 3, 2025 · 1 comment

Comments

@samuelstroschein
Copy link
Member

samuelstroschein commented Mar 3, 2025

Context

SSG needs to know the localized URLs in advance. Sitemap generation also needs to know what localized URLs exist.

Proposal

A new generateStaticPaths() which goes through the URL patterns and returns the list of localizedUrls.

The developer provides a list of all static URLs/paths, the function will match the paths and return a list of all localized URLs.

const localizedUrls = generateStaticLocalizedUrls([
  "/example",
  "/page/blog",
  "/123/hello"
])

console.log(localizedUrls)
>> /de/example
>> /fr/example
>> ...

A sitemap generator can take the URLs and generate the sitemap. Likewise can an SSG generator statically pre-render all sites.

@mquandalle
Copy link

This will also be useful to generate <link rel="alternate" hreflang="XXX" url="XXX" /> tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants