@uniweb/core 0.37.0 → 0.37.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.37.0",
3
+ "version": "0.37.1",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
@@ -49,8 +49,8 @@
49
49
  "vitest": "^4.1.7"
50
50
  },
51
51
  "dependencies": {
52
- "@uniweb/semantic-parser": "^1.5.1",
53
- "@uniweb/theming": "^0.2.0"
52
+ "@uniweb/theming": "^0.2.0",
53
+ "@uniweb/semantic-parser": "^1.5.1"
54
54
  },
55
55
  "scripts": {
56
56
  "test": "vitest run"
@@ -297,6 +297,27 @@ export function recordTitle(record) {
297
297
  return undefined
298
298
  }
299
299
 
300
+ /**
301
+ * A record's SHARED IMAGE — what a link to the page about it shows (its `og:image`).
302
+ *
303
+ * ONE RULE, read where `recordTitle` is: the parametric page (`Website._createDynamicPage`)
304
+ * and the static build's page expansion. It is the record's `image` — the card's picture,
305
+ * which a page names itself from as it does from the card's title — and it takes the
306
+ * place of the page's own `seo.image`, which then serves a record that has none. A site's
307
+ * `seo.image` comes last (`Page.getHeadMeta`).
308
+ *
309
+ * Only a non-empty string is an image: a localized map or an object is structure this
310
+ * rule cannot write into a meta tag.
311
+ *
312
+ * @param {Object} record
313
+ * @returns {string|undefined}
314
+ */
315
+ export function recordImage(record) {
316
+ if (!record || typeof record !== 'object') return undefined
317
+ const image = record.image
318
+ return typeof image === 'string' && image.trim() !== '' ? image : undefined
319
+ }
320
+
300
321
  /**
301
322
  * The record field a route param is matched on — ONE MAP, read by the local match
302
323
  * (`routeParamValue`, below) and by the records service's record question (`match`,
package/src/website.js CHANGED
@@ -11,7 +11,7 @@ import FetcherDispatcher from './fetcher-dispatcher.js'
11
11
  import ObservableState from './observable-state.js'
12
12
  import { normalizeSeo } from './seo.js'
13
13
  import { resolveDefaultLocale, localeLabel } from './locale-config.js'
14
- import { matchDynamicRoute, recordTitle, routeBinding, routeParamName, parentRouteOf } from './route-match.js'
14
+ import { matchDynamicRoute, recordTitle, recordImage, routeBinding, routeParamName, parentRouteOf } from './route-match.js'
15
15
  import { resolveFetchConfigs, pageRouteQuery, recordPages } from './fetch-config.js'
16
16
  import { declaredKeys } from './data-keys.js'
17
17
  import { pageRecordConfig, planFor, runPlanSync } from './page-data.js'
@@ -636,6 +636,11 @@ export default class Website {
636
636
  if (currentItem.description || currentItem.excerpt) {
637
637
  pageData.description = currentItem.description || currentItem.excerpt
638
638
  }
639
+ // ⭐ And by its picture: a link to the page shows the record's image (`recordImage`).
640
+ // ⛔ Until 2026-10-05 it showed the page's or the site's `seo.image`, the same for
641
+ // every record.
642
+ const image = recordImage(currentItem)
643
+ if (image) pageData.seo = { ...(pageData.seo || {}), image }
639
644
  } else if (answered) {
640
645
  // The cache answered and the record is not there: the set is loaded and this ID is
641
646
  // not in it, or the record question answered `[]` — definitive not found.