@uniweb/core 0.5.4 → 0.5.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
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.2"
33
+ "@uniweb/semantic-parser": "1.1.3"
34
34
  },
35
35
  "scripts": {
36
36
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
package/src/block.js CHANGED
@@ -7,6 +7,21 @@
7
7
 
8
8
  import { parseContent as parseSemanticContent } from '@uniweb/semantic-parser'
9
9
 
10
+ /**
11
+ * Resolve bare palette references to var() in theme overrides.
12
+ * Allows content authors to write `primary: neutral-900` in frontmatter
13
+ * instead of `primary: var(--neutral-900)`.
14
+ */
15
+ const SHADE_LEVELS = new Set([50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950])
16
+
17
+ function resolveOverrideValue(value) {
18
+ if (typeof value !== 'string' || value.includes('(') || value.startsWith('#')) return value
19
+ const bare = value.replace(/^-{0,2}/, '')
20
+ const match = bare.match(/^([a-z][a-z0-9]*)-(\d+)$/)
21
+ if (match && SHADE_LEVELS.has(parseInt(match[2], 10))) return `var(--${bare})`
22
+ return value
23
+ }
24
+
10
25
  export default class Block {
11
26
  constructor(blockData, id, page) {
12
27
  this.id = id
@@ -42,11 +57,19 @@ export default class Block {
42
57
  this.preset = blockData.preset
43
58
 
44
59
  // Normalize theme: supports string ("light") or object ({ mode, ...tokenOverrides })
60
+ // Resolve bare palette refs (e.g. "primary: neutral-900" → var(--neutral-900))
45
61
  const rawTheme = blockConfig.theme
46
62
  if (rawTheme && typeof rawTheme === 'object') {
47
63
  const { mode, ...overrides } = rawTheme
48
64
  this.themeName = mode || 'light'
49
- this.contextOverrides = Object.keys(overrides).length > 0 ? overrides : null
65
+ if (Object.keys(overrides).length > 0) {
66
+ for (const key of Object.keys(overrides)) {
67
+ overrides[key] = resolveOverrideValue(overrides[key])
68
+ }
69
+ this.contextOverrides = overrides
70
+ } else {
71
+ this.contextOverrides = null
72
+ }
50
73
  } else {
51
74
  this.themeName = rawTheme || 'light'
52
75
  this.contextOverrides = null
package/src/website.js CHANGED
@@ -243,6 +243,14 @@ export default class Website {
243
243
  if (routeId && !this._pageIdMap.has(routeId)) {
244
244
  this._pageIdMap.set(routeId, page)
245
245
  }
246
+ // Folder-name fallback — allows page:home for homepage, page:docs/intro for index pages
247
+ // Homepage route normalizes to '' (falsy, skipped above), but sourcePath '/home' → 'home' works
248
+ if (page.sourcePath) {
249
+ const folderId = page.sourcePath.replace(/^\//, '').replace(/\/$/, '')
250
+ if (folderId && !this._pageIdMap.has(folderId)) {
251
+ this._pageIdMap.set(folderId, page)
252
+ }
253
+ }
246
254
  }
247
255
  }
248
256