@uniweb/core 0.30.0 → 0.30.1

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 +28 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.30.0",
3
+ "version": "0.30.1",
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
@@ -527,10 +527,31 @@ export default class Website {
527
527
  const indexMatch = this.pages.find((page) => page.isIndex && page.getNavRoute() === normalizedRoute)
528
528
  if (indexMatch) return indexMatch
529
529
 
530
- // Priority 3: Dynamic route pattern matching
531
- // Check cache first
532
- if (this._dynamicPageCache.has(normalizedRoute)) {
533
- return this._dynamicPageCache.get(normalizedRoute)
530
+ // Priority 3: Dynamic route pattern matching — on the canonical route, then on the display route,
531
+ // as Priorities 1 and 1b match a static page in either payload shape. A published payload's
532
+ // parametric page carries its locale's own pattern (`/noticias/:slug`), which only the display
533
+ // route matches. ⛔ Until 2026-09-26 only the canonical route was tried, so a backend-served
534
+ // site's `/es/noticias/x` showed the not-found page without asking for its record. The canonical
535
+ // route goes first so a file-lane site — whose patterns are all canonical — matches as before.
536
+ for (const candidate of new Set([normalizedRoute, normalizedStripped])) {
537
+ const found = this._matchDynamicPage(candidate)
538
+ if (found) return found
539
+ }
540
+
541
+ return undefined
542
+ }
543
+
544
+ /**
545
+ * The dynamic page a concrete route names, from the cache or a fresh match of the dynamic
546
+ * patterns — or undefined.
547
+ *
548
+ * @private
549
+ * @param {string} route - a concrete route, in the form the page patterns are matched against
550
+ * @returns {Page|undefined}
551
+ */
552
+ _matchDynamicPage(route) {
553
+ if (this._dynamicPageCache.has(route)) {
554
+ return this._dynamicPageCache.get(route)
534
555
  }
535
556
 
536
557
  // Try to match against dynamic route patterns
@@ -538,23 +559,22 @@ export default class Website {
538
559
  // Check if this is a dynamic page (has :param in route)
539
560
  if (!page.route.includes(':')) continue
540
561
 
541
- const match = this._matchDynamicRoute(page.route, normalizedRoute)
562
+ const match = this._matchDynamicRoute(page.route, route)
542
563
  if (match) {
543
564
  // Create a dynamic page instance with the concrete route and params
544
- const result = this._createDynamicPage(page, normalizedRoute, match.params)
565
+ const result = this._createDynamicPage(page, route, match.params)
545
566
  if (result) {
546
567
  const { page: dynamicPage, recordsLoaded } = result
547
568
  // Only cache when the records were available at creation time.
548
569
  // If DataStore was empty, skip caching so the next render recreates
549
570
  // the page with fresh data (correct title, not-found state, etc.).
550
571
  if (recordsLoaded) {
551
- this._dynamicPageCache.set(normalizedRoute, dynamicPage)
572
+ this._dynamicPageCache.set(route, dynamicPage)
552
573
  }
553
574
  return dynamicPage
554
575
  }
555
576
  }
556
577
  }
557
-
558
578
  return undefined
559
579
  }
560
580