@uniweb/core 1.3.1 → 1.4.0
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.
- package/package.json +1 -1
- package/src/block.js +45 -10
- package/src/page.js +14 -0
- package/src/route-match.js +15 -1
- package/src/website.js +5 -0
package/package.json
CHANGED
package/src/block.js
CHANGED
|
@@ -74,22 +74,34 @@ export default class Block {
|
|
|
74
74
|
const blockConfig = blockData.params || blockData.config || {}
|
|
75
75
|
|
|
76
76
|
// ⭐ THE SECTION'S OWN SETTINGS — the names framework reserves in its params
|
|
77
|
-
// (`@uniweb/schemas/section`): `theme`, `background`, `grid`, `vars`, `fetch`.
|
|
78
|
-
// each — the runtime paints the background and the color context around
|
|
79
|
-
// the
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
// 2026-09-28]. It reads them from the
|
|
83
|
-
// also received `theme` (the mode),
|
|
84
|
-
// them there. ⛔ An editor's older
|
|
85
|
-
// — is no longer read
|
|
86
|
-
//
|
|
77
|
+
// (`@uniweb/schemas/section`): `theme`, `background`, `grid`, `vars`, `fetch`, `sticky`.
|
|
78
|
+
// Framework applies each — the runtime paints the background and the color context around
|
|
79
|
+
// the component and makes sticky the box that can stick, the page stylesheet applies the
|
|
80
|
+
// section's theme and its component's variables, kit's `ChildGrid` lays out the child
|
|
81
|
+
// sections — so each is lifted onto the block, normalized once for every renderer, and a
|
|
82
|
+
// component NEVER receives one as a param [Diego, 2026-09-28]. It reads them from the
|
|
83
|
+
// block, or through kit. ⛔ Until then a component also received `theme` (the mode),
|
|
84
|
+
// `background` and `vars` as params, and nothing read them there. ⛔ An editor's older
|
|
85
|
+
// envelope — `params.standardOptions` and `params.properties` — is no longer read
|
|
86
|
+
// (2026-09-28): an editor's preview sends a section's params as stored, and no store
|
|
87
|
+
// publishes the envelope. Either name is an ordinary param now.
|
|
87
88
|
const {
|
|
88
89
|
theme: rawTheme, background: rawBg, grid: gridParam, vars: varsParam, fetch: fetchParam,
|
|
90
|
+
sticky: stickyParam,
|
|
89
91
|
...componentParams
|
|
90
92
|
} = blockConfig
|
|
91
93
|
this.properties = componentParams
|
|
92
94
|
|
|
95
|
+
// Whether the section stays in view as the page scrolls — what the author wrote (`true` or
|
|
96
|
+
// `false`; anything else is no answer), else its type's default from `meta.js`, which
|
|
97
|
+
// `initComponent` reads, else not. The runtime applies it to the box that can stick: a
|
|
98
|
+
// component's own markup sits in boxes as tall as itself, where `sticky` cannot move
|
|
99
|
+
// (2026-10-19).
|
|
100
|
+
this.stickySetting = typeof stickyParam === 'boolean' ? stickyParam : null
|
|
101
|
+
this.sticky = this.stickySetting ?? false
|
|
102
|
+
// How far below the top it stays — its type's `top`, a CSS length; null is the very top.
|
|
103
|
+
this.stickyTop = null
|
|
104
|
+
|
|
93
105
|
// The section's theme: `theme.yml`'s own keys scoped to the section — `colors`,
|
|
94
106
|
// `contexts`, `vars` — plus `mode`, the color context it pins. `theme: dark` is the
|
|
95
107
|
// shorthand for `{ mode: dark }`, and a token written beside `mode` applies to the section
|
|
@@ -506,9 +518,32 @@ export default class Block {
|
|
|
506
518
|
this.componentVars = Block.mergeComponentVars(meta.vars, this.sectionVars)
|
|
507
519
|
}
|
|
508
520
|
|
|
521
|
+
// The type's `sticky`: `true`, or `{ default, top }` — the author's value wins.
|
|
522
|
+
const sticky = Block.normalizeStickyDeclaration(meta.sticky)
|
|
523
|
+
this.sticky = this.stickySetting ?? sticky.default
|
|
524
|
+
this.stickyTop = sticky.top
|
|
525
|
+
|
|
509
526
|
return this.Component
|
|
510
527
|
}
|
|
511
528
|
|
|
529
|
+
/**
|
|
530
|
+
* A section type's `sticky` declaration, as `meta.js` may write it: `true` or `false`, or
|
|
531
|
+
* `{ default, top }` — `top` a CSS length, for a type that sits below another sticking
|
|
532
|
+
* element.
|
|
533
|
+
*
|
|
534
|
+
* @param {*} declared
|
|
535
|
+
* @returns {{ default: boolean, top: string|null }}
|
|
536
|
+
*/
|
|
537
|
+
static normalizeStickyDeclaration(declared) {
|
|
538
|
+
if (declared && typeof declared === 'object') {
|
|
539
|
+
return {
|
|
540
|
+
default: declared.default === true,
|
|
541
|
+
top: typeof declared.top === 'string' && declared.top.trim() ? declared.top.trim() : null,
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return { default: declared === true, top: null }
|
|
545
|
+
}
|
|
546
|
+
|
|
512
547
|
/**
|
|
513
548
|
* Get block properties
|
|
514
549
|
*/
|
package/src/page.js
CHANGED
|
@@ -376,6 +376,20 @@ export default class Page {
|
|
|
376
376
|
return result
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
/**
|
|
380
|
+
* Whether a layout area stays in view as the page scrolls: any of its sections is sticky
|
|
381
|
+
* (`sticky:`, a setting of the section). The runtime makes sticky the box it gives the area;
|
|
382
|
+
* a layout that wraps the area in an element of its own makes THAT element sticky when this
|
|
383
|
+
* is true, since a box sticks only within its parent, and the area's sits in the layout's.
|
|
384
|
+
*
|
|
385
|
+
* @param {string} areaName
|
|
386
|
+
* @returns {boolean}
|
|
387
|
+
*/
|
|
388
|
+
isSticky(areaName) {
|
|
389
|
+
const blocks = this.getLayoutAreas()[areaName]
|
|
390
|
+
return Array.isArray(blocks) && blocks.some((block) => block.sticky)
|
|
391
|
+
}
|
|
392
|
+
|
|
379
393
|
/**
|
|
380
394
|
* Get layout params for this page (merged with defaults at render time)
|
|
381
395
|
* @returns {Object}
|
package/src/route-match.js
CHANGED
|
@@ -527,6 +527,13 @@ export function routeParamName(pattern, declared = null) {
|
|
|
527
527
|
* included — when a page holds that route. A top-level page has none: the homepage
|
|
528
528
|
* is not everyone's parent.
|
|
529
529
|
*
|
|
530
|
+
* ⭐ Past a version folder, the versioned section. In `docs/v1/` + `docs/v2/` the latest
|
|
531
|
+
* version's pages sit at `/docs/…` and hang from `/docs`; an older one's sit at
|
|
532
|
+
* `/docs/v1/…`, and `/docs/v1` is a folder, never a page — so they hang from `/docs` too.
|
|
533
|
+
* The segment is a version by the build's own convention (`v1`, `v2.1`). ⛔ Until
|
|
534
|
+
* 2026-10-19 they had no parent: every menu listed them as top-level pages, and no
|
|
535
|
+
* branch of the tree held them.
|
|
536
|
+
*
|
|
530
537
|
* ⛔ Measured 2026-09-11, before this existed: the prefetch read the declared field
|
|
531
538
|
* only, so on a payload without it `/members/alice` resolved no configs at all,
|
|
532
539
|
* while the SPA inferred `/members` and fetched the list and the record itself.
|
|
@@ -544,9 +551,16 @@ export function parentRouteOf(route, { declared = null, has } = {}) {
|
|
|
544
551
|
const cut = r.lastIndexOf('/')
|
|
545
552
|
if (cut <= 0) return null
|
|
546
553
|
const up = r.slice(0, cut)
|
|
547
|
-
|
|
554
|
+
if (has(up)) return up
|
|
555
|
+
const versionCut = up.lastIndexOf('/')
|
|
556
|
+
if (versionCut <= 0 || !VERSION_SEGMENT.test(up.slice(versionCut + 1))) return null
|
|
557
|
+
const section = up.slice(0, versionCut)
|
|
558
|
+
return has(section) ? section : null
|
|
548
559
|
}
|
|
549
560
|
|
|
561
|
+
/** A version folder's name — `v1`, `v2.1` — the build's convention for a versioned section. */
|
|
562
|
+
const VERSION_SEGMENT = /^v\d+(\.\d+)?$/
|
|
563
|
+
|
|
550
564
|
/**
|
|
551
565
|
* The base route a record's URL composes onto, for a page that ADDRESSES ONE RECORD —
|
|
552
566
|
* or null when the page is not one.
|
package/src/website.js
CHANGED
|
@@ -1275,6 +1275,11 @@ export default class Website {
|
|
|
1275
1275
|
// These are templates for generating pages, not actual navigable pages
|
|
1276
1276
|
if (page.route.includes(':')) return false
|
|
1277
1277
|
|
|
1278
|
+
// ⭐ And the pages made from one — a record's own page (/blog/my-post). The SPA keeps
|
|
1279
|
+
// those out of `this.pages` (`_dynamicPageCache`), but a static build expands them into
|
|
1280
|
+
// ordinary pages, and they joined every menu there: a blog's menu listed each article.
|
|
1281
|
+
if (page.dynamicContext) return false
|
|
1282
|
+
|
|
1278
1283
|
// Exclude index pages (route ends in /index) from navigation — they are
|
|
1279
1284
|
// represented by their parent folder entry which links to them via navigableRoute
|
|
1280
1285
|
if (page.isIndex && page.route.endsWith('/index')) return false
|