@uniweb/core 0.7.7 → 0.7.9

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 +2 -2
  2. package/src/page.js +28 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.7.7",
3
+ "version": "0.7.9",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
@@ -30,7 +30,7 @@
30
30
  "jest": "^29.7.0"
31
31
  },
32
32
  "dependencies": {
33
- "@uniweb/semantic-parser": "1.1.14",
33
+ "@uniweb/semantic-parser": "1.1.16",
34
34
  "@uniweb/theming": "0.1.3"
35
35
  },
36
36
  "scripts": {
package/src/page.js CHANGED
@@ -480,6 +480,34 @@ export default class Page {
480
480
  return this.route // Fallback to own route
481
481
  }
482
482
 
483
+ /**
484
+ * Resolve which Page should actually be rendered when this one is
485
+ * requested. If the page has its own content, it renders itself. If
486
+ * it's a content-less folder with a designated index child, that
487
+ * child renders in its place. Otherwise, returns `this` so the caller
488
+ * can decide what to do with an empty page (typically an empty
489
+ * <main>, not a 404 — the route exists, it just has no body).
490
+ *
491
+ * Distinct from `getNavigableRoute()`, which recursively walks
492
+ * descendants to find a navigation target. `getRenderableSelf()` only
493
+ * looks one level down (to the immediate index child) — the contract
494
+ * is "give me the page to render *here*," not "give me the next URL
495
+ * with content."
496
+ *
497
+ * Used by SSR paths (Cloudflare Worker isolate today; framework SSG
498
+ * pre-handles this differently via expandDynamicPages) to avoid
499
+ * rendering nothing when an author requests `/docs` and the page is
500
+ * a folder whose actual landing content lives in `/docs/intro` flagged
501
+ * as `isIndex: true`.
502
+ *
503
+ * @returns {Page} The page to render — `this` or its index child.
504
+ */
505
+ getRenderableSelf() {
506
+ if (this.hasContent()) return this
507
+ const indexChild = this.children?.find((c) => c.isIndex)
508
+ return indexChild || this
509
+ }
510
+
483
511
  /**
484
512
  * Get route without leading/trailing slashes.
485
513
  * Delegates to Website.normalizeRoute() for consistent normalization.