reroute-js 1.0.0-alpha.39 → 1.0.0-alpha.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. package/README.md +34 -0
  2. package/cli/bin.d.ts +1 -1
  3. package/cli/bin.js +231 -50
  4. package/cli/bin.js.map +13 -13
  5. package/cli/index.d.ts +1 -1
  6. package/cli/index.js +8 -5
  7. package/cli/index.js.map +11 -10
  8. package/cli/src/cli.d.ts +1 -1
  9. package/cli/src/commands/analyze.d.ts +1 -1
  10. package/cli/src/commands/build.d.ts +1 -1
  11. package/cli/src/commands/dev.d.ts +1 -1
  12. package/cli/src/commands/gen.d.ts +1 -1
  13. package/cli/src/commands/gen.d.ts.map +1 -1
  14. package/cli/src/commands/index.d.ts +1 -1
  15. package/cli/src/commands/init.d.ts +1 -1
  16. package/cli/src/commands/lib/assets.d.ts +1 -1
  17. package/cli/src/commands/lib/bundler.d.ts +1 -1
  18. package/cli/src/commands/lib/command.d.ts +1 -1
  19. package/cli/src/commands/lib/env.d.ts +1 -1
  20. package/cli/src/commands/lib/images.d.ts +1 -1
  21. package/cli/src/commands/lib/index.d.ts +1 -1
  22. package/cli/src/commands/lib/log.d.ts +1 -1
  23. package/cli/src/commands/lib/markdown/availability.d.ts +1 -1
  24. package/cli/src/commands/lib/markdown/index.d.ts +1 -1
  25. package/cli/src/commands/lib/markdown/processor.d.ts +1 -1
  26. package/cli/src/commands/lib/prerender.d.ts +1 -1
  27. package/cli/src/commands/lib/production.d.ts +1 -1
  28. package/cli/src/commands/lib/routes.d.ts +1 -1
  29. package/cli/src/commands/lib/server.d.ts +1 -1
  30. package/cli/src/commands/lib/ssr-strip.d.ts +1 -1
  31. package/cli/src/commands/lib/static.d.ts +1 -1
  32. package/cli/src/commands/lib/streaming/analyzer.d.ts +1 -1
  33. package/cli/src/commands/lib/streaming/suspense.d.ts +1 -1
  34. package/cli/src/commands/lib/supervise.d.ts +1 -1
  35. package/cli/src/commands/lib/terminal-ui.d.ts +1 -1
  36. package/cli/src/commands/lib/theme.d.ts +1 -1
  37. package/cli/src/commands/lib/version.d.ts +1 -1
  38. package/cli/src/commands/lib/watch.d.ts +1 -1
  39. package/cli/src/commands/og.d.ts +1 -1
  40. package/cli/src/commands/start.d.ts +1 -1
  41. package/cli/src/commands/static-render.d.ts +1 -1
  42. package/cli/src/index.d.ts +1 -1
  43. package/core/index.d.ts +1 -1
  44. package/core/index.js +221 -46
  45. package/core/index.js.map +12 -12
  46. package/core/src/app-paths.d.ts +1 -1
  47. package/core/src/bundler/hash.d.ts +1 -1
  48. package/core/src/bundler/index.d.ts +1 -1
  49. package/core/src/config.d.ts +1 -1
  50. package/core/src/content/discovery.d.ts +1 -1
  51. package/core/src/content/index.d.ts +1 -1
  52. package/core/src/content/metadata.d.ts +1 -1
  53. package/core/src/i18n/catalog.d.ts +1 -1
  54. package/core/src/i18n/discover.d.ts +1 -1
  55. package/core/src/i18n/discover.d.ts.map +1 -1
  56. package/core/src/i18n/index.d.ts +2 -2
  57. package/core/src/i18n/index.d.ts.map +1 -1
  58. package/core/src/i18n/messages.d.ts +1 -1
  59. package/core/src/i18n/negotiate.d.ts +1 -1
  60. package/core/src/i18n/pathname.d.ts +32 -4
  61. package/core/src/i18n/pathname.d.ts.map +1 -1
  62. package/core/src/i18n/resolve.d.ts +3 -2
  63. package/core/src/i18n/resolve.d.ts.map +1 -1
  64. package/core/src/i18n/types.d.ts +44 -1
  65. package/core/src/i18n/types.d.ts.map +1 -1
  66. package/core/src/image.d.ts +1 -1
  67. package/core/src/index.d.ts +1 -1
  68. package/core/src/llms/discovery.d.ts +1 -1
  69. package/core/src/llms/extractor.d.ts +1 -1
  70. package/core/src/llms/formatter.d.ts +1 -1
  71. package/core/src/llms/full-generator.d.ts +1 -1
  72. package/core/src/llms/index-generator.d.ts +1 -1
  73. package/core/src/llms/index.d.ts +1 -1
  74. package/core/src/og/discovery.d.ts +1 -1
  75. package/core/src/og/index.d.ts +1 -1
  76. package/core/src/og/meta.d.ts +1 -1
  77. package/core/src/og/render.d.ts +1 -1
  78. package/core/src/og/types.d.ts +1 -1
  79. package/core/src/robots/discovery.d.ts +1 -1
  80. package/core/src/robots/generator.d.ts +1 -1
  81. package/core/src/robots/index.d.ts +1 -1
  82. package/core/src/robots/policies.d.ts +1 -1
  83. package/core/src/rss/discovery.d.ts +1 -1
  84. package/core/src/rss/generator.d.ts +1 -1
  85. package/core/src/rss/index.d.ts +1 -1
  86. package/core/src/sitemap/discovery.d.ts +1 -1
  87. package/core/src/sitemap/generator.d.ts +12 -2
  88. package/core/src/sitemap/generator.d.ts.map +1 -1
  89. package/core/src/sitemap/index.d.ts +1 -1
  90. package/core/src/ssr/index.d.ts +1 -1
  91. package/core/src/ssr/lib/cache.d.ts +1 -1
  92. package/core/src/ssr/lib/cleanup.d.ts +1 -1
  93. package/core/src/ssr/lib/collections.d.ts +1 -1
  94. package/core/src/ssr/lib/compression.d.ts +1 -1
  95. package/core/src/ssr/lib/compute/content.d.ts +1 -1
  96. package/core/src/ssr/lib/compute/index.d.ts +1 -1
  97. package/core/src/ssr/lib/compute/layouts.d.ts +1 -1
  98. package/core/src/ssr/lib/compute/layouts.d.ts.map +1 -1
  99. package/core/src/ssr/lib/compute/routes.d.ts +1 -1
  100. package/core/src/ssr/lib/compute/routes.d.ts.map +1 -1
  101. package/core/src/ssr/lib/content-path.d.ts +13 -2
  102. package/core/src/ssr/lib/content-path.d.ts.map +1 -1
  103. package/core/src/ssr/lib/data.d.ts +1 -1
  104. package/core/src/ssr/lib/html.d.ts +1 -1
  105. package/core/src/ssr/lib/imports.d.ts +1 -1
  106. package/core/src/ssr/lib/index.d.ts +1 -1
  107. package/core/src/ssr/lib/layouts.d.ts +1 -1
  108. package/core/src/ssr/lib/metadata.d.ts +1 -1
  109. package/core/src/ssr/lib/metadata.d.ts.map +1 -1
  110. package/core/src/ssr/lib/mime.d.ts +1 -1
  111. package/core/src/ssr/lib/modules.d.ts +1 -1
  112. package/core/src/ssr/lib/path.d.ts +1 -1
  113. package/core/src/ssr/lib/preload.d.ts +1 -1
  114. package/core/src/ssr/lib/route-match.d.ts +1 -1
  115. package/core/src/ssr/lib/scripts/collections.d.ts +1 -1
  116. package/core/src/ssr/lib/scripts/data.d.ts +1 -1
  117. package/core/src/ssr/lib/scripts/escape.d.ts +1 -1
  118. package/core/src/ssr/lib/scripts/feeds.d.ts +1 -1
  119. package/core/src/ssr/lib/scripts/index.d.ts +1 -1
  120. package/core/src/ssr/lib/seed.d.ts +1 -1
  121. package/core/src/ssr/lib/serialize.d.ts +1 -1
  122. package/core/src/ssr/lib/setup.d.ts +1 -1
  123. package/core/src/ssr/lib/styles.d.ts +1 -1
  124. package/core/src/ssr/lib/template.d.ts +1 -1
  125. package/core/src/ssr/lib/types.d.ts +7 -1
  126. package/core/src/ssr/lib/types.d.ts.map +1 -1
  127. package/core/src/ssr/render.d.ts +1 -1
  128. package/core/src/ssr/stream.d.ts +1 -1
  129. package/core/src/ssr/stream.d.ts.map +1 -1
  130. package/elysia/index.d.ts +1 -1
  131. package/elysia/index.js +370 -87
  132. package/elysia/index.js.map +18 -17
  133. package/elysia/src/index.d.ts +1 -1
  134. package/elysia/src/libs/assets.d.ts +1 -1
  135. package/elysia/src/libs/cache.d.ts +1 -1
  136. package/elysia/src/libs/caching.d.ts +1 -1
  137. package/elysia/src/libs/devReload.d.ts +1 -1
  138. package/elysia/src/libs/http.d.ts +1 -1
  139. package/elysia/src/libs/i18n.d.ts +14 -3
  140. package/elysia/src/libs/i18n.d.ts.map +1 -1
  141. package/elysia/src/libs/image.d.ts +1 -1
  142. package/elysia/src/libs/index.d.ts +1 -1
  143. package/elysia/src/libs/lazyData.d.ts +38 -0
  144. package/elysia/src/libs/lazyData.d.ts.map +1 -0
  145. package/elysia/src/libs/llms.d.ts +1 -1
  146. package/elysia/src/libs/response.d.ts +1 -1
  147. package/elysia/src/libs/serving.d.ts +1 -1
  148. package/elysia/src/plugin.d.ts +1 -1
  149. package/elysia/src/routes/artifacts.d.ts +1 -1
  150. package/elysia/src/routes/content.d.ts +1 -1
  151. package/elysia/src/routes/image.d.ts +1 -1
  152. package/elysia/src/routes/index.d.ts +1 -1
  153. package/elysia/src/routes/internal.d.ts +1 -1
  154. package/elysia/src/routes/internal.d.ts.map +1 -1
  155. package/elysia/src/routes/liveReloadClient.d.ts +1 -1
  156. package/elysia/src/routes/llms.d.ts +1 -1
  157. package/elysia/src/routes/og.d.ts +1 -1
  158. package/elysia/src/routes/redirects.d.ts +1 -1
  159. package/elysia/src/routes/robots.d.ts +1 -1
  160. package/elysia/src/routes/rss.d.ts +1 -1
  161. package/elysia/src/routes/search.d.ts +1 -1
  162. package/elysia/src/routes/sitemap.d.ts +1 -1
  163. package/elysia/src/routes/sitemap.d.ts.map +1 -1
  164. package/elysia/src/routes/ssr.d.ts +1 -1
  165. package/elysia/src/routes/ssr.d.ts.map +1 -1
  166. package/elysia/src/routes/static.d.ts +1 -1
  167. package/elysia/src/routes/themeCssRefresh.d.ts +1 -1
  168. package/elysia/src/types.d.ts +1 -1
  169. package/package.json +1 -1
  170. package/react/index.d.ts +1 -1
  171. package/react/index.js +85 -20
  172. package/react/index.js.map +6 -6
  173. package/react/src/components/ClientOnly.d.ts +1 -1
  174. package/react/src/components/ContentRoute.d.ts +1 -1
  175. package/react/src/components/Image.d.ts +1 -1
  176. package/react/src/components/LazyRoute.d.ts +1 -1
  177. package/react/src/components/Link.d.ts +1 -1
  178. package/react/src/components/Markdown.d.ts +1 -1
  179. package/react/src/components/Outlet.d.ts +1 -1
  180. package/react/src/components/index.d.ts +1 -1
  181. package/react/src/hooks/index.d.ts +1 -1
  182. package/react/src/hooks/useContent.d.ts +1 -1
  183. package/react/src/hooks/useData.d.ts +1 -1
  184. package/react/src/hooks/useFeed.d.ts +1 -1
  185. package/react/src/hooks/useLayoutData.d.ts +1 -1
  186. package/react/src/hooks/useLlms.d.ts +1 -1
  187. package/react/src/hooks/useNavigate.d.ts +1 -1
  188. package/react/src/hooks/useParams.d.ts +1 -1
  189. package/react/src/hooks/useRouter.d.ts +1 -1
  190. package/react/src/hooks/useSearch.d.ts +1 -1
  191. package/react/src/hooks/useSearchParams.d.ts +1 -1
  192. package/react/src/hooks/useToc.d.ts +1 -1
  193. package/react/src/i18n/LocaleProvider.d.ts +20 -2
  194. package/react/src/i18n/LocaleProvider.d.ts.map +1 -1
  195. package/react/src/i18n/helpers.d.ts +31 -3
  196. package/react/src/i18n/helpers.d.ts.map +1 -1
  197. package/react/src/i18n/index.d.ts +2 -2
  198. package/react/src/i18n/index.d.ts.map +1 -1
  199. package/react/src/index.d.ts +1 -1
  200. package/react/src/lib/bundle.d.ts +1 -1
  201. package/react/src/lib/collection.d.ts +1 -1
  202. package/react/src/lib/content.d.ts +1 -1
  203. package/react/src/lib/head.d.ts +1 -1
  204. package/react/src/lib/index.d.ts +1 -1
  205. package/react/src/lib/layouts.d.ts +1 -1
  206. package/react/src/lib/lazy-route.d.ts +1 -1
  207. package/react/src/lib/route-loader.d.ts +1 -1
  208. package/react/src/lib/static-data.d.ts +1 -1
  209. package/react/src/providers/ContentProvider.d.ts +1 -1
  210. package/react/src/providers/RerouteProvider.d.ts +1 -1
  211. package/react/src/providers/RerouteProvider.d.ts.map +1 -1
  212. package/react/src/providers/RouterProvider.d.ts +4 -2
  213. package/react/src/providers/RouterProvider.d.ts.map +1 -1
  214. package/react/src/providers/index.d.ts +1 -1
  215. package/react/src/types/any.d.ts +1 -1
  216. package/react/src/types/index.d.ts +1 -1
  217. package/react/src/types/router.d.ts +7 -1
  218. package/react/src/types/router.d.ts.map +1 -1
  219. package/telemetry/react.d.ts +1 -1
  220. package/telemetry/react.js +2 -2
  221. package/telemetry/react.js.map +1 -1
  222. package/telemetry/server.d.ts +1 -1
  223. package/telemetry/server.js +6 -3
  224. package/telemetry/server.js.map +11 -10
  225. package/telemetry/src/react/api.d.ts +1 -1
  226. package/telemetry/src/react/context.d.ts +1 -1
  227. package/telemetry/src/react/index.d.ts +1 -1
  228. package/telemetry/src/react/telemetry.d.ts +1 -1
  229. package/telemetry/src/server/context.d.ts +1 -1
  230. package/telemetry/src/server/headers/extractor.d.ts +1 -1
  231. package/telemetry/src/server/headers/index.d.ts +1 -1
  232. package/telemetry/src/server/headers/presets.d.ts +1 -1
  233. package/telemetry/src/server/index.d.ts +1 -1
  234. package/telemetry/src/server/instrumentation.d.ts +1 -1
  235. package/telemetry/src/server/plugin.d.ts +1 -1
  236. package/telemetry/src/server/sourcemap.d.ts +1 -1
package/README.md CHANGED
@@ -678,6 +678,37 @@ src/client/routes/blog/content/
678
678
  - `setLocale()` writes `?lang=` and the server 302s to the canonical content URL (and sets the cookie). That is the only way to leave a URL that already has a locale in the path
679
679
  - Optional negotiate: `Accept-Language` / cookie can 302 **unprefixed** content URLs to a localized path (`i18n.redirectContentOnNegotiate`, default `true`)
680
680
 
681
+ ### Locale-prefixed pages (`i18n.prefixPages`)
682
+
683
+ Off by default. With `prefixPages: true` every page carries its locale in the URL, so each response depends on its URL alone and a CDN that caches by URL never serves one visitor's language to the next:
684
+
685
+ | URL | Locale |
686
+ |-----|--------|
687
+ | `/compare` | default |
688
+ | `/pt-BR/compare`, `/pt-BR` | pt-BR |
689
+ | `/help/pt-BR/slug` | pt-BR (content keeps its format) |
690
+
691
+ - The cookie and `Accept-Language` never pick a page's locale, and page/data responses send no `Set-Cookie`
692
+ - `/en-US/compare` 301s to `/compare`; a prefix in front of a content URL (`/pt-BR/help/slug`) 301s to `/help/pt-BR/slug`
693
+ - `?lang=xx` 302s to that locale's URL (and only that redirect sets the cookie); `setLocale()` uses it
694
+ - `<Link to="/compare">` renders `/pt-BR/compare` on a pt-BR page; a path that names a locale (`/pt-BR/...`) is left as written, and a link to another locale loads the document
695
+ - `ssr.data` gets the full path as `pathname` (`/pt-BR/compare`), so data is keyed and cached per locale; routes, layouts and params match the unprefixed path
696
+ - Every page gets `hreflang` alternates for each locale plus `x-default`; the sitemap lists each page once per locale
697
+ - `unprefixedPaths: ['/portfolio', '/auth']`: pages that keep one URL for every locale (a PWA scope, a universal link, a payment return). `/portfolio` covers `/portfolio/...`, not `/portfolios`. A prefixed one (`/pt-BR/portfolio`) 301s to its bare URL; otherwise its locale comes from `?lang=`, the cookie or `Accept-Language`, as without `prefixPages`, and it may set the cookie, so don't let a CDN cache it. `Link` leaves them as written, they get no `hreflang`, and the sitemap lists them once. A link from a locale-prefixed page to one loads the document
698
+ - `useRouter().routingPathname` is the path routes match (`/pt-BR/compare` → `/compare`): compare it, not `pathname`, to literals such as `'/'`
699
+
700
+ #### One URL per page, the CDN picks the locale (`localeParam`)
701
+
702
+ For pages shared as one link (a public profile), where `/pt-BR/...` URLs don't fit: a CDN reads the visitor's language and adds it as a query parameter that is part of its cache key, and the page renders in that locale.
703
+
704
+ ```ts
705
+ i18n: { localeParam: '__locale' },
706
+ ```
707
+
708
+ - The page's locale is that parameter (a content URL's segment still wins), else the default. The cookie, `Accept-Language` and `?lang=` are never read, nothing redirects and no cookie is set, so each response is a function of its URL and the CDN may cache it
709
+ - The CDN adds the parameter to every request, `/__reroute_data` included (reroute reads it from the data request's own query). With Cloudflare, a URL Rewrite Transform Rule: when `starts_with(lower(http.request.headers["accept-language"][0]), "pt")`, set the query to `concat(http.request.uri.query, "&__locale=pt-BR")`
710
+ - Without the CDN (local dev), pages render in the default locale; add `?__locale=pt-BR` to see another
711
+
681
712
  ### UI Strings
682
713
 
683
714
  ```tsx
@@ -719,6 +750,9 @@ export default defineConfig({
719
750
  localesDir: 'locales', // catalog directory
720
751
  cookie: 'reroute-locale',
721
752
  redirectContentOnNegotiate: true, // 302 default content → localized URL
753
+ prefixPages: false, // true: /pt-BR/compare, URL-only locale
754
+ unprefixedPaths: [], // with prefixPages: paths never prefixed
755
+ localeParam: '', // '__locale': a CDN names the locale in the query
722
756
  },
723
757
  });
724
758
  ```
package/cli/bin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * reroute-js v1.0.0-alpha.39
2
+ * reroute-js v1.0.0-alpha.40
3
3
  *
4
4
  * @license MIT
5
5
  * @copyright 2026 stewones <hi@stewan.io>
package/cli/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
3
  /**
4
- * reroute-js v1.0.0-alpha.39
4
+ * reroute-js v1.0.0-alpha.40
5
5
  *
6
6
  * @license MIT
7
7
  * @copyright 2026 stewones <hi@stewan.io>
@@ -68,7 +68,7 @@ async function getVersionString() {
68
68
  }
69
69
  async function getVersion() {
70
70
  if (true) {
71
- return "1.0.0-alpha.39";
71
+ return "1.0.0-alpha.40";
72
72
  }
73
73
  const possiblePaths = [
74
74
  path.join(import.meta.dir, "../../../../package.json"),
@@ -86,7 +86,7 @@ async function getVersion() {
86
86
  }
87
87
  async function getCommit() {
88
88
  if (true) {
89
- return "f8c30d1";
89
+ return "90d5401";
90
90
  }
91
91
  return "dev";
92
92
  }
@@ -624,6 +624,9 @@ async function discoverI18n(cwd, options = {}) {
624
624
  const defaultLocale = options.defaultLocale ?? DEFAULT_LOCALE;
625
625
  const cookie = options.cookie ?? DEFAULT_COOKIE;
626
626
  const redirectContentOnNegotiate = options.redirectContentOnNegotiate ?? true;
627
+ const prefixPages = options.prefixPages ?? false;
628
+ const unprefixedPaths = options.unprefixedPaths ?? [];
629
+ const localeParam = options.localeParam ?? "";
627
630
  const absDir = join3(cwd, localesDir);
628
631
  const disabled = {
629
632
  enabled: false,
@@ -632,6 +635,9 @@ async function discoverI18n(cwd, options = {}) {
632
635
  localesDir,
633
636
  cookie,
634
637
  redirectContentOnNegotiate,
638
+ prefixPages,
639
+ unprefixedPaths,
640
+ localeParam,
635
641
  catalogs: {}
636
642
  };
637
643
  let catalogs;
@@ -655,6 +661,9 @@ async function discoverI18n(cwd, options = {}) {
655
661
  localesDir,
656
662
  cookie,
657
663
  redirectContentOnNegotiate,
664
+ prefixPages,
665
+ unprefixedPaths,
666
+ localeParam,
658
667
  catalogs
659
668
  };
660
669
  }
@@ -755,11 +764,15 @@ var exports_pathname = {};
755
764
  __export(exports_pathname, {
756
765
  contentKey: () => contentKey,
757
766
  hreflangTags: () => hreflangTags,
767
+ isUnprefixedPath: () => isUnprefixedPath,
758
768
  localizeContentHref: () => localizeContentHref,
759
769
  localizeHref: () => localizeHref,
770
+ localizePagePath: () => localizePagePath,
760
771
  looksLikeLocale: () => looksLikeLocale,
761
772
  normalizePathname: () => normalizePathname,
773
+ pageHreflangTags: () => pageHreflangTags,
762
774
  parseContentPath: () => parseContentPath,
775
+ parseLocalePrefix: () => parseLocalePrefix,
763
776
  toOgLocale: () => toOgLocale
764
777
  });
765
778
  function looksLikeLocale(segment) {
@@ -807,13 +820,36 @@ function localizeContentHref(collection, name, locale, defaultLocale) {
807
820
  }
808
821
  return `/${collection}/${locale}/${name}`;
809
822
  }
810
- function localizeHref(to, locale, defaultLocale, availableLocales = [], collections) {
823
+ function parseLocalePrefix(pathname, availableLocales) {
824
+ const [, segment = "", ...rest] = normalizePathname(pathname).split("/");
825
+ const locale = availableLocales.find((l) => l.toLowerCase() === segment.toLowerCase());
826
+ if (!locale)
827
+ return;
828
+ return { locale, segment, routingPathname: `/${rest.join("/")}` };
829
+ }
830
+ function localizePagePath(pathname, locale, defaultLocale) {
831
+ if (locale === defaultLocale)
832
+ return pathname;
833
+ return pathname === "/" ? `/${locale}` : `/${locale}${pathname}`;
834
+ }
835
+ function isUnprefixedPath(pathname, unprefixedPaths = []) {
836
+ const path2 = normalizePathname(pathname);
837
+ return unprefixedPaths.some((prefix) => {
838
+ const base = prefix.replace(/\/+$/, "");
839
+ return base === "" || path2 === base || path2.startsWith(`${base}/`);
840
+ });
841
+ }
842
+ function localizeHref(to, locale, defaultLocale, availableLocales = [], collections, prefixPages) {
811
843
  try {
812
844
  const url = new URL(to, "http://local");
813
- const parsed = parseContentPath(url.pathname, availableLocales, collections);
814
- if (!parsed)
845
+ const parsed = parseContentPath(url.pathname, availableLocales, prefixPages ? collections ?? [] : collections);
846
+ if (parsed) {
847
+ url.pathname = localizeContentHref(parsed.collection, parsed.name, locale, defaultLocale);
848
+ } else if (prefixPages && to.startsWith("/") && url.origin === "http://local" && !/\.[^/]+$/.test(url.pathname) && !parseLocalePrefix(url.pathname, availableLocales) && !isUnprefixedPath(url.pathname, prefixPages.unprefixedPaths)) {
849
+ url.pathname = localizePagePath(url.pathname, locale, defaultLocale);
850
+ } else {
815
851
  return to;
816
- url.pathname = localizeContentHref(parsed.collection, parsed.name, locale, defaultLocale);
852
+ }
817
853
  return `${url.pathname}${url.search}${url.hash}`;
818
854
  } catch {
819
855
  return to;
@@ -828,18 +864,20 @@ function contentKey(collection, name, locale, defaultLocale = "en-US") {
828
864
  function toOgLocale(locale) {
829
865
  return locale.replace(/-/g, "_");
830
866
  }
831
- function hreflangTags(baseUrl, collection, name, locales, defaultLocale) {
867
+ function alternateLinks(baseUrl, locales, defaultLocale, pathFor) {
832
868
  const base = baseUrl.replace(/\/$/, "");
833
- const tags = [];
834
- for (const locale of locales) {
835
- const path2 = localizeContentHref(collection, name, locale, defaultLocale);
836
- tags.push(`<link rel="alternate" hreflang="${locale}" href="${base}${path2}" />`);
837
- }
838
- const defaultPath = localizeContentHref(collection, name, defaultLocale, defaultLocale);
839
- tags.push(`<link rel="alternate" hreflang="x-default" href="${base}${defaultPath}" />`);
840
- return tags.join(`
869
+ return [...locales, "x-default"].map((hreflang) => {
870
+ const path2 = pathFor(hreflang === "x-default" ? defaultLocale : hreflang);
871
+ return `<link rel="alternate" hreflang="${hreflang}" href="${base}${path2}" />`;
872
+ }).join(`
841
873
  `);
842
874
  }
875
+ function hreflangTags(baseUrl, collection, name, locales, defaultLocale) {
876
+ return alternateLinks(baseUrl, locales, defaultLocale, (locale) => localizeContentHref(collection, name, locale, defaultLocale));
877
+ }
878
+ function pageHreflangTags(baseUrl, routingPathname, locales, defaultLocale) {
879
+ return alternateLinks(baseUrl, locales, defaultLocale, (locale) => localizePagePath(routingPathname, locale, defaultLocale));
880
+ }
843
881
  var init_pathname = () => {};
844
882
 
845
883
  // packages/core/src/i18n/resolve.ts
@@ -863,7 +901,71 @@ function stripLangParam(search) {
863
901
  const rest = params.toString();
864
902
  return rest ? `?${rest}` : "";
865
903
  }
904
+ function unprefix(pagePathname, search, defaultLocale) {
905
+ const query = search ? `?${search.replace(/^\?/, "")}` : "";
906
+ return {
907
+ locale: defaultLocale,
908
+ routingPathname: pagePathname,
909
+ fromPath: true,
910
+ fromQuery: false,
911
+ redirectTo: `${pagePathname}${query}`,
912
+ permanent: true,
913
+ urlOnly: true
914
+ };
915
+ }
916
+ function resolvePrefixedLocale(input) {
917
+ const prefix = parseLocalePrefix(input.pathname, input.availableLocales);
918
+ const pagePathname = prefix?.routingPathname ?? normalizePathname(input.pathname);
919
+ if (!isUnprefixedPath(pagePathname, input.unprefixedPaths)) {
920
+ return resolvePrefixedPage(input, prefix, pagePathname);
921
+ }
922
+ return prefix ? unprefix(pagePathname, input.search, input.defaultLocale) : resolveNegotiatedLocale(input);
923
+ }
924
+ function resolvePrefixedPage(input, prefix, pagePathname) {
925
+ const { search, availableLocales, defaultLocale } = input;
926
+ const isAvailable = (locale2) => !!locale2 && availableLocales.some((l) => l.toLowerCase() === locale2.toLowerCase());
927
+ const parsed = parseContentPath(pagePathname, availableLocales, input.collections ?? []);
928
+ const urlLocale = parsed?.locale ?? prefix?.locale ?? defaultLocale;
929
+ const queryLocale = parseLangParam(search, isAvailable, availableLocales);
930
+ const locale = queryLocale ?? urlLocale;
931
+ const misplaced = !!prefix && (!!parsed || prefix.locale === defaultLocale || prefix.segment !== prefix.locale);
932
+ const defaultSegment = !prefix && parsed?.locale === defaultLocale;
933
+ const canonical = parsed ? localizeContentHref(parsed.collection, parsed.name, locale, defaultLocale) : localizePagePath(pagePathname, locale, defaultLocale);
934
+ return {
935
+ locale,
936
+ routingPathname: parsed?.routingPathname ?? pagePathname,
937
+ fromPath: !!(parsed?.locale || prefix),
938
+ fromQuery: !!queryLocale,
939
+ redirectTo: queryLocale || misplaced || defaultSegment ? `${canonical}${stripLangParam(search)}` : undefined,
940
+ permanent: !queryLocale && (misplaced || defaultSegment),
941
+ urlOnly: true,
942
+ parsed: parsed ? { ...parsed, locale } : undefined
943
+ };
944
+ }
945
+ function resolveParamLocale(input, localeParam) {
946
+ const { pathname, search, availableLocales, defaultLocale } = input;
947
+ const parsed = parseContentPath(pathname, availableLocales, input.collections);
948
+ const named = new URLSearchParams(search ?? "").get(localeParam);
949
+ const param = named ? availableLocales.find((l) => l.toLowerCase() === named.toLowerCase()) : undefined;
950
+ const pathLocale = parsed?.locale && canonicalLocale(parsed.locale, availableLocales);
951
+ const locale = pathLocale || param || defaultLocale;
952
+ return {
953
+ locale,
954
+ routingPathname: parsed?.routingPathname ?? normalizePathname(pathname),
955
+ fromPath: !!pathLocale,
956
+ fromQuery: false,
957
+ urlOnly: true,
958
+ parsed: parsed ? { ...parsed, locale: pathLocale || undefined } : undefined
959
+ };
960
+ }
866
961
  function resolveLocale(input) {
962
+ if (input.prefixPages)
963
+ return resolvePrefixedLocale(input);
964
+ if (input.localeParam)
965
+ return resolveParamLocale(input, input.localeParam);
966
+ return resolveNegotiatedLocale(input);
967
+ }
968
+ function resolveNegotiatedLocale(input) {
867
969
  const {
868
970
  pathname,
869
971
  search,
@@ -1754,7 +1856,9 @@ function matchRoutes(routes, pathname) {
1754
1856
  // packages/core/src/ssr/lib/content-path.ts
1755
1857
  var exports_content_path = {};
1756
1858
  __export(exports_content_path, {
1757
- resolveContentPathParts: () => resolveContentPathParts
1859
+ pagePathname: () => pagePathname,
1860
+ resolveContentPathParts: () => resolveContentPathParts,
1861
+ routingPathname: () => routingPathname
1758
1862
  });
1759
1863
  function resolveContentPathParts(pathname) {
1760
1864
  const pathOnly = pathname.split("?")[0].split("#")[0];
@@ -1792,6 +1896,17 @@ function resolveContentPathParts(pathname) {
1792
1896
  routingPathname: `/${parts.join("/")}`
1793
1897
  };
1794
1898
  }
1899
+ function pagePathname(pathname) {
1900
+ const pathOnly = pathname.split("?")[0].split("#")[0];
1901
+ const i18n = globalThis.__REROUTE_I18N__;
1902
+ if (!i18n?.prefixPages)
1903
+ return pathOnly;
1904
+ return parseLocalePrefix(pathOnly, i18n.locales || [])?.routingPathname ?? pathOnly;
1905
+ }
1906
+ function routingPathname(pathname) {
1907
+ const page = pagePathname(pathname);
1908
+ return resolveContentPathParts(page)?.routingPathname ?? page;
1909
+ }
1795
1910
  var init_content_path = __esm(() => {
1796
1911
  init_pathname();
1797
1912
  });
@@ -2034,7 +2149,7 @@ async function computeLayoutData(pathname, clientDir, _cwd, isWatchMode, options
2034
2149
  try {
2035
2150
  const layouts = routesModule?.layouts;
2036
2151
  const routes = routesModule?.routes;
2037
- const matchingLayouts = getMatchingLayouts(pathname, layouts, routes);
2152
+ const matchingLayouts = getMatchingLayouts(routingPathname(pathname), layouts, routes);
2038
2153
  for (const layout of matchingLayouts) {
2039
2154
  try {
2040
2155
  const layoutStatus = await processLayout(layout, pathname, clientDir, isWatchMode, streaming, maxAgeMs, searchParams, ssrData, pendingTasks, options.headers);
@@ -2063,6 +2178,7 @@ function mergeLayoutData(ssrData, pathname) {
2063
2178
  }
2064
2179
  var init_layouts2 = __esm(() => {
2065
2180
  init_cache();
2181
+ init_content_path();
2066
2182
  init_imports();
2067
2183
  init_layouts();
2068
2184
  });
@@ -2107,9 +2223,7 @@ async function computeRouteData(pathname, clientDir, _cwd, isWatchMode, options,
2107
2223
  }).catch(() => {}));
2108
2224
  };
2109
2225
  try {
2110
- const resolved = resolveContentPathParts(pathname);
2111
- const pathnameOnly = (resolved?.routingPathname || pathname).split("?")[0];
2112
- const match = typeof routesModule?.matchRoute === "function" ? routesModule.matchRoute(pathnameOnly) : null;
2226
+ const match = typeof routesModule?.matchRoute === "function" ? routesModule.matchRoute(routingPathname(pathname)) : null;
2113
2227
  const route = match?.route;
2114
2228
  const params = match?.params || {};
2115
2229
  if (!route || typeof route.path !== "string") {
@@ -3105,9 +3219,8 @@ async function extractPageMetadata(pathname, clientDir, cwd, isWatchMode, curren
3105
3219
  let perPageHead = "";
3106
3220
  let pageLang;
3107
3221
  let statusOverride = currentStatusOverride;
3108
- const resolved = resolveContentPathParts(pathname);
3109
- const routingPathname = resolved?.routingPathname || pathname;
3110
- await extractLayoutMetadata(routingPathname, clientDir, cwd, isWatchMode, (head) => {
3222
+ const routingPathname2 = routingPathname(pathname);
3223
+ await extractLayoutMetadata(routingPathname2, pathname, clientDir, cwd, isWatchMode, (head) => {
3111
3224
  perPageHead += head;
3112
3225
  }, (lang) => {
3113
3226
  if (!pageLang)
@@ -3143,11 +3256,14 @@ ${ogMetaTags}`;
3143
3256
  }, (lang) => {
3144
3257
  pageLang = lang;
3145
3258
  }, ogConfig, titleSuffix, baseUrl);
3146
- const routeResult = await extractRouteMetadata(pathname, clientDir, cwd, isWatchMode, statusOverride, ssrData, ogConfig, titleSuffix, routingPathname);
3259
+ const routeResult = await extractRouteMetadata(pathname, clientDir, cwd, isWatchMode, statusOverride, ssrData, ogConfig, titleSuffix, routingPathname2);
3147
3260
  perPageHead += routeResult.head;
3148
3261
  if (routeResult.lang)
3149
3262
  pageLang = routeResult.lang;
3150
3263
  statusOverride = routeResult.statusOverride;
3264
+ if (baseUrl && !(statusOverride && statusOverride >= 400)) {
3265
+ perPageHead += pageI18nHead(baseUrl, pathname);
3266
+ }
3151
3267
  return {
3152
3268
  perPageHead,
3153
3269
  pageLang,
@@ -3155,7 +3271,7 @@ ${ogMetaTags}`;
3155
3271
  ssrExport: routeResult.ssrExport
3156
3272
  };
3157
3273
  }
3158
- async function processLayoutForMetadata(layout, clientDir, isWatchMode, addHead, setLang, ogConfig, titleSuffix) {
3274
+ async function processLayoutForMetadata(layout, requestPathname, clientDir, isWatchMode, addHead, setLang, ogConfig, titleSuffix) {
3159
3275
  if (typeof layout?.path !== "string")
3160
3276
  return;
3161
3277
  try {
@@ -3164,7 +3280,7 @@ async function processLayoutForMetadata(layout, clientDir, isWatchMode, addHead,
3164
3280
  if (meta)
3165
3281
  addHead(buildHeadFromMeta(meta, ogConfig, titleSuffix));
3166
3282
  if (ssr) {
3167
- const ssrHead = extractSSRHead(ssr, undefined, ogConfig, undefined, meta, titleSuffix);
3283
+ const ssrHead = extractSSRHead(ssr, requestPathname, undefined, ogConfig, undefined, meta, titleSuffix);
3168
3284
  if (ssrHead)
3169
3285
  addHead(`
3170
3286
  ${ssrHead}`);
@@ -3174,15 +3290,36 @@ ${ssrHead}`);
3174
3290
  }
3175
3291
  } catch {}
3176
3292
  }
3177
- async function extractLayoutMetadata(pathname, clientDir, cwd, isWatchMode, addHead, setLang, ogConfig, titleSuffix) {
3293
+ async function extractLayoutMetadata(pathname, requestPathname, clientDir, cwd, isWatchMode, addHead, setLang, ogConfig, titleSuffix) {
3178
3294
  try {
3179
3295
  const m = await loadRoutesModule(cwd, isWatchMode);
3180
3296
  const matchingLayouts = getMatchingLayouts(pathname, m?.layouts, m?.routes);
3181
3297
  for (const layout of matchingLayouts) {
3182
- await processLayoutForMetadata(layout, clientDir, isWatchMode, addHead, setLang, ogConfig, titleSuffix);
3298
+ await processLayoutForMetadata(layout, requestPathname, clientDir, isWatchMode, addHead, setLang, ogConfig, titleSuffix);
3183
3299
  }
3184
3300
  } catch {}
3185
3301
  }
3302
+ function readI18n() {
3303
+ return globalThis.__REROUTE_I18N__;
3304
+ }
3305
+ function isContentUrl(i18n, collection) {
3306
+ return !i18n.prefixPages || !!i18n.collections?.includes(collection);
3307
+ }
3308
+ function pageI18nHead(baseUrl, pathname) {
3309
+ const i18n = readI18n();
3310
+ if (!(i18n?.enabled && i18n.prefixPages && i18n.locales))
3311
+ return "";
3312
+ if (i18n.locales.length < 2)
3313
+ return "";
3314
+ const resolved = resolveContentPathParts(pathname);
3315
+ if (resolved && isContentUrl(i18n, resolved.collection))
3316
+ return "";
3317
+ const page = pagePathname(pathname);
3318
+ if (isUnprefixedPath(page, i18n.unprefixedPaths))
3319
+ return "";
3320
+ return `
3321
+ ${pageHreflangTags(baseUrl, page, i18n.locales, i18n.defaultLocale || "en-US")}`;
3322
+ }
3186
3323
  function resolveContentLocales(collection, name, fallbackLocales) {
3187
3324
  const g = globalThis;
3188
3325
  const byCollection = g.__REROUTE_COLLECTIONS__;
@@ -3222,15 +3359,15 @@ function extractContentMetadata(pathname, addHead, setLang, ogConfig, titleSuffi
3222
3359
  const meta = exp?.meta;
3223
3360
  const ssr = exp?.ssr;
3224
3361
  addHead(buildHeadFromMeta(meta, ogConfig, titleSuffix));
3225
- const ssrHead = extractSSRHead(ssr, undefined, ogConfig, undefined, meta, titleSuffix);
3362
+ const ssrHead = extractSSRHead(ssr, pathname, undefined, ogConfig, undefined, meta, titleSuffix);
3226
3363
  if (ssrHead)
3227
3364
  addHead(`
3228
3365
  ${ssrHead}`);
3229
3366
  const lang = extractSSRLang(ssr);
3230
3367
  if (lang)
3231
3368
  setLang(lang);
3232
- const i18n = g.__REROUTE_I18N__;
3233
- if (i18n?.enabled && baseUrl && i18n.locales && i18n.locales.length > 1) {
3369
+ const i18n = readI18n();
3370
+ if (i18n?.enabled && baseUrl && i18n.locales && i18n.locales.length > 1 && isContentUrl(i18n, resolved.collection)) {
3234
3371
  const locales = resolveContentLocales(resolved.collection, resolved.name, i18n.locales);
3235
3372
  addContentI18nHead(addHead, baseUrl, resolved.collection, resolved.name, locales, i18n.defaultLocale || "en-US", i18n.locale || i18n.defaultLocale || "en-US");
3236
3373
  }
@@ -3256,9 +3393,9 @@ function getContentMetaFromExports(pathname) {
3256
3393
  return;
3257
3394
  }
3258
3395
  }
3259
- async function extractMatchedRouteMetadata(pathname, clientDir, m, isWatchMode, statusOverride, ssrData, ogConfig, titleSuffix, routingPathname) {
3396
+ async function extractMatchedRouteMetadata(pathname, clientDir, m, isWatchMode, statusOverride, ssrData, ogConfig, titleSuffix, routingPathname2) {
3260
3397
  const pathnameOnly = pathname.split("?")[0];
3261
- const matchPath = (routingPathname || pathname).split("?")[0];
3398
+ const matchPath = (routingPathname2 || pathname).split("?")[0];
3262
3399
  const match = typeof m.matchRoute === "function" ? m.matchRoute(matchPath) : null;
3263
3400
  const r = match?.route;
3264
3401
  if (!r) {
@@ -3283,7 +3420,7 @@ async function extractMatchedRouteMetadata(pathname, clientDir, m, isWatchMode,
3283
3420
  }
3284
3421
  const contentMeta = getContentMetaFromExports(pathnameOnly);
3285
3422
  const headMeta = contentMeta || meta;
3286
- const ssrHead = extractSSRHead(ssr, routeData, ogConfig, head, headMeta, titleSuffix);
3423
+ const ssrHead = extractSSRHead(ssr, pathname, routeData, ogConfig, head, headMeta, titleSuffix);
3287
3424
  if (ssrHead)
3288
3425
  head += `
3289
3426
  ${ssrHead}`;
@@ -3299,7 +3436,7 @@ ${ssrHead}`;
3299
3436
  }
3300
3437
  return { head: "", statusOverride };
3301
3438
  }
3302
- async function extractRouteMetadata(pathname, clientDir, cwd, isWatchMode, currentStatusOverride, ssrData, ogConfig, titleSuffix, routingPathname) {
3439
+ async function extractRouteMetadata(pathname, clientDir, cwd, isWatchMode, currentStatusOverride, ssrData, ogConfig, titleSuffix, routingPathname2) {
3303
3440
  let head = "";
3304
3441
  let lang;
3305
3442
  let statusOverride = currentStatusOverride;
@@ -3309,14 +3446,14 @@ async function extractRouteMetadata(pathname, clientDir, cwd, isWatchMode, curre
3309
3446
  if (!m) {
3310
3447
  return { head, lang, statusOverride: statusOverride || 404 };
3311
3448
  }
3312
- const matchPath = (routingPathname || pathname).split("?")[0];
3449
+ const matchPath = (routingPathname2 || pathname).split("?")[0];
3313
3450
  const match = typeof m.matchRoute === "function" ? m.matchRoute(matchPath) : null;
3314
3451
  const r = match?.route;
3315
3452
  if (!r) {
3316
3453
  statusOverride = statusOverride || 404;
3317
3454
  }
3318
3455
  if (r && typeof r.path === "string") {
3319
- const result = await extractMatchedRouteMetadata(pathname, clientDir, m, isWatchMode, statusOverride, ssrData, ogConfig, titleSuffix, routingPathname);
3456
+ const result = await extractMatchedRouteMetadata(pathname, clientDir, m, isWatchMode, statusOverride, ssrData, ogConfig, titleSuffix, routingPathname2);
3320
3457
  head = result.head;
3321
3458
  lang = result.lang;
3322
3459
  statusOverride = result.statusOverride;
@@ -3356,7 +3493,7 @@ async function extractNotFoundMetadata(pathname, clientDir, routesModule, isWatc
3356
3493
  const { meta, ssr } = await loadModuleMetaAndSSR(chosen, abs, isWatchMode);
3357
3494
  if (meta)
3358
3495
  head += buildHeadFromMeta(meta, ogConfig, titleSuffix);
3359
- const ssrHead = extractSSRHead(ssr, undefined, ogConfig, undefined, meta, titleSuffix);
3496
+ const ssrHead = extractSSRHead(ssr, pathname, undefined, ogConfig, undefined, meta, titleSuffix);
3360
3497
  if (ssrHead)
3361
3498
  head += `
3362
3499
  ${ssrHead}`;
@@ -3419,13 +3556,17 @@ function generateMissingOGTags(head, ogConfig) {
3419
3556
  ${additionalTags.join(`
3420
3557
  `)}` : "";
3421
3558
  }
3422
- function extractSSRHead(ssr, data, ogConfig, existingHead, meta, titleSuffix) {
3559
+ function extractSSRHead(ssr, pathname, data, ogConfig, existingHead, meta, titleSuffix) {
3423
3560
  if (!ssr)
3424
3561
  return "";
3425
3562
  let headContent = "";
3426
3563
  if (typeof ssr.head === "function") {
3427
3564
  try {
3428
- const result = ssr.head({ data, meta });
3565
+ const result = ssr.head({
3566
+ pathname,
3567
+ data,
3568
+ meta
3569
+ });
3429
3570
  if (typeof result === "string")
3430
3571
  headContent = result;
3431
3572
  else if (Array.isArray(result))
@@ -6557,18 +6698,43 @@ function createStaticEntry(route, baseUrl, defaultChangefreq, defaultPriority) {
6557
6698
  priority: route.priority !== undefined ? route.priority : loc === "/" ? 1 : defaultPriority
6558
6699
  };
6559
6700
  }
6560
- function collectAllEntries(discovery4, baseUrl, changefreq, priority, excludeRoutes) {
6701
+ function localizePageEntry(entry, baseUrl, i18n) {
6702
+ const base = baseUrl.replace(/\/$/, "");
6703
+ if (!(i18n && entry.loc.startsWith(base)))
6704
+ return [entry];
6705
+ const path3 = entry.loc.slice(base.length) || "/";
6706
+ if (parseContentPath(path3, i18n.locales, i18n.collections))
6707
+ return [entry];
6708
+ if (isUnprefixedPath(path3, i18n.unprefixedPaths))
6709
+ return [entry];
6710
+ const { locales, defaultLocale } = i18n;
6711
+ const urlFor = (locale) => `${base}${localizePagePath(path3, locale, defaultLocale)}`;
6712
+ const alternates = [
6713
+ ...locales.map((locale) => ({ hreflang: locale, href: urlFor(locale) })),
6714
+ { hreflang: "x-default", href: urlFor(defaultLocale) }
6715
+ ];
6716
+ return locales.map((locale) => ({
6717
+ ...entry,
6718
+ loc: urlFor(locale),
6719
+ alternates
6720
+ }));
6721
+ }
6722
+ function collectAllEntries(discovery4, baseUrl, changefreq, priority, excludeRoutes, i18n) {
6561
6723
  const allEntries = [];
6724
+ const addPage = (entry) => {
6725
+ allEntries.push(...localizePageEntry(entry, baseUrl, i18n));
6726
+ };
6562
6727
  for (const route of discovery4.staticRoutes) {
6563
6728
  if (shouldIncludeRoute(route.pattern, excludeRoutes)) {
6564
- allEntries.push(createStaticEntry(route, baseUrl, changefreq, priority));
6729
+ addPage(createStaticEntry(route, baseUrl, changefreq, priority));
6565
6730
  }
6566
6731
  }
6567
6732
  for (const [_collection, entries] of discovery4.collections.entries()) {
6568
6733
  allEntries.push(...entries);
6569
6734
  }
6570
6735
  for (const [_pattern, entries] of discovery4.ssrDataRoutes.entries()) {
6571
- allEntries.push(...entries);
6736
+ for (const entry of entries)
6737
+ addPage(entry);
6572
6738
  }
6573
6739
  return allEntries;
6574
6740
  }
@@ -6614,7 +6780,7 @@ async function generateSitemap(discovery4, baseUrl, options = {}) {
6614
6780
  priority = 0.5,
6615
6781
  maxUrlsPerPage = DEFAULT_MAX_URLS
6616
6782
  } = options;
6617
- const allEntries = collectAllEntries(discovery4, baseUrl, changefreq, priority, options.excludeRoutes);
6783
+ const allEntries = collectAllEntries(discovery4, baseUrl, changefreq, priority, options.excludeRoutes, options.i18n);
6618
6784
  sortEntries(allEntries);
6619
6785
  const needsIndex = allEntries.length > maxUrlsPerPage;
6620
6786
  if (needsIndex) {
@@ -6674,7 +6840,9 @@ function escapeXml2(unsafe) {
6674
6840
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
6675
6841
  }
6676
6842
  var DEFAULT_MAX_URLS = 50000;
6677
- var init_generator2 = () => {};
6843
+ var init_generator2 = __esm(() => {
6844
+ init_pathname();
6845
+ });
6678
6846
 
6679
6847
  // packages/core/src/sitemap/index.ts
6680
6848
  var init_sitemap = __esm(() => {
@@ -6944,7 +7112,10 @@ function generateMetaUpdateScript(ctx, ssrDataSnapshot) {
6944
7112
  }
6945
7113
  let headResult;
6946
7114
  try {
6947
- headResult = ctx.ssrExport.head({ data: routeData });
7115
+ headResult = ctx.ssrExport.head({
7116
+ pathname: ctx.pathname,
7117
+ data: routeData
7118
+ });
6948
7119
  } catch (err) {
6949
7120
  console.error("[reroute] Error calling ssr.head() at stream end:", err);
6950
7121
  return "";
@@ -7164,6 +7335,7 @@ __export(exports_core, {
7164
7335
  inlineThemeCSS: () => inlineThemeCSS,
7165
7336
  isCompressible: () => isCompressible,
7166
7337
  isThenable: () => isThenable,
7338
+ isUnprefixedPath: () => isUnprefixedPath,
7167
7339
  join: () => join2,
7168
7340
  layoutCovers: () => layoutCovers,
7169
7341
  layoutWraps: () => layoutWraps,
@@ -7176,6 +7348,7 @@ __export(exports_core, {
7176
7348
  loadRoutesModule: () => loadRoutesModule,
7177
7349
  localizeContentHref: () => localizeContentHref,
7178
7350
  localizeHref: () => localizeHref,
7351
+ localizePagePath: () => localizePagePath,
7179
7352
  looksLikeLocale: () => looksLikeLocale,
7180
7353
  lookupMessage: () => lookupMessage,
7181
7354
  markPageHead: () => markPageHead,
@@ -7186,8 +7359,10 @@ __export(exports_core, {
7186
7359
  mergeVary: () => mergeVary,
7187
7360
  negotiateLocale: () => negotiateLocale,
7188
7361
  normalizePathname: () => normalizePathname,
7362
+ pageHreflangTags: () => pageHreflangTags,
7189
7363
  parseContentPath: () => parseContentPath,
7190
7364
  parseCookieValue: () => parseCookieValue,
7365
+ parseLocalePrefix: () => parseLocalePrefix,
7191
7366
  performSSRSetup: () => performSSRSetup,
7192
7367
  preloadContentModule: () => preloadContentModule,
7193
7368
  processCollections: () => processCollections,
@@ -9822,6 +9997,9 @@ async function generate(cwd, args = [], options = {}) {
9822
9997
  locales: i18n2.locales,
9823
9998
  cookie: i18n2.cookie,
9824
9999
  redirectContentOnNegotiate: i18n2.redirectContentOnNegotiate,
10000
+ prefixPages: i18n2.prefixPages,
10001
+ unprefixedPaths: i18n2.unprefixedPaths,
10002
+ localeParam: i18n2.localeParam,
9825
10003
  catalogs: i18n2.catalogs
9826
10004
  }, null, 2));
9827
10005
  if (i18n2.enabled && !showPerformance) {
@@ -10306,6 +10484,9 @@ async function startGenWatch(cwd, args) {
10306
10484
  locales: watchI18n.locales,
10307
10485
  cookie: watchI18n.cookie,
10308
10486
  redirectContentOnNegotiate: watchI18n.redirectContentOnNegotiate,
10487
+ prefixPages: watchI18n.prefixPages,
10488
+ unprefixedPaths: watchI18n.unprefixedPaths,
10489
+ localeParam: watchI18n.localeParam,
10309
10490
  catalogs: watchI18n.catalogs
10310
10491
  }, null, 2));
10311
10492
  await buildContentChunks(cwd, args, watchI18n.defaultLocale, watchPaths.routesDir);
@@ -108844,7 +109025,7 @@ async function getVersionString2() {
108844
109025
  }
108845
109026
  async function getVersion2() {
108846
109027
  if (true) {
108847
- return "1.0.0-alpha.39";
109028
+ return "1.0.0-alpha.40";
108848
109029
  }
108849
109030
  const possiblePaths = [
108850
109031
  path3.join(import.meta.dir, "../../../package.json"),
@@ -108861,10 +109042,10 @@ async function getVersion2() {
108861
109042
  }
108862
109043
  async function getCommit2() {
108863
109044
  if (true) {
108864
- return "f8c30d1";
109045
+ return "90d5401";
108865
109046
  }
108866
109047
  return "dev";
108867
109048
  }
108868
109049
  main();
108869
109050
 
108870
- //# debugId=9CD3B704ACE54A9D64756E2164756E21
109051
+ //# debugId=4DCB742915D0BED964756E2164756E21