@uniweb/core 0.3.6 → 0.3.7

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/website.js +14 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
package/src/website.js CHANGED
@@ -172,9 +172,22 @@ export default class Website {
172
172
  * @returns {Page|undefined}
173
173
  */
174
174
  getPage(route) {
175
+ // Strip locale prefix if present (e.g., '/fr/about' → '/about')
176
+ // Pages are stored with non-prefixed routes; the locale is a URL concern,
177
+ // not a page identity concern.
178
+ let stripped = route
179
+ if (this.activeLocale && this.activeLocale !== this.defaultLocale) {
180
+ const prefix = `/${this.activeLocale}`
181
+ if (stripped === prefix || stripped === `${prefix}/`) {
182
+ stripped = '/'
183
+ } else if (stripped.startsWith(`${prefix}/`)) {
184
+ stripped = stripped.slice(prefix.length)
185
+ }
186
+ }
187
+
175
188
  // Normalize trailing slashes for consistent matching
176
189
  // '/about/' and '/about' should match the same page
177
- const normalizedRoute = route === '/' ? '/' : route.replace(/\/$/, '')
190
+ const normalizedRoute = stripped === '/' ? '/' : stripped.replace(/\/$/, '')
178
191
 
179
192
  // Priority 1: Exact match on actual route
180
193
  const exactMatch = this.pages.find((page) => page.route === normalizedRoute)