@uniweb/core 1.6.4 → 1.6.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 +1 -1
- package/src/route-match.js +27 -0
- package/src/website.js +6 -4
package/package.json
CHANGED
package/src/route-match.js
CHANGED
|
@@ -334,6 +334,33 @@ export function recordImage(record) {
|
|
|
334
334
|
return typeof image === 'string' && image.trim() !== '' ? image : undefined
|
|
335
335
|
}
|
|
336
336
|
|
|
337
|
+
/**
|
|
338
|
+
* A record's DESCRIPTION — the line the page about it is described by (its meta description),
|
|
339
|
+
* and the line under it in a search result and in `llms.txt`.
|
|
340
|
+
*
|
|
341
|
+
* ONE RULE, read where `recordTitle` is: the parametric page (`Website._createDynamicPage`), the
|
|
342
|
+
* static build's page expansion, and the record search index (`@uniweb/projections`).
|
|
343
|
+
*
|
|
344
|
+
* description → excerpt
|
|
345
|
+
*
|
|
346
|
+
* Only a non-empty string describes a record. A rich-text field named `description` is a
|
|
347
|
+
* document, which this rule cannot write into a meta tag, so it is passed over for `excerpt`.
|
|
348
|
+
* ⛔ Until 2026-11-06 the page and the build took either field as it came, so a rich-text
|
|
349
|
+
* `description` described the page as `[object Object]`, and the search index never read
|
|
350
|
+
* either: its excerpt was the record's strings run together, icon names and colours included,
|
|
351
|
+
* and `llms.txt` described each record's page with it.
|
|
352
|
+
*
|
|
353
|
+
* @param {Object} record
|
|
354
|
+
* @returns {string|undefined}
|
|
355
|
+
*/
|
|
356
|
+
export function recordDescription(record) {
|
|
357
|
+
if (!record || typeof record !== 'object') return undefined
|
|
358
|
+
for (const value of [record.description, record.excerpt]) {
|
|
359
|
+
if (typeof value === 'string' && value.trim() !== '') return value
|
|
360
|
+
}
|
|
361
|
+
return undefined
|
|
362
|
+
}
|
|
363
|
+
|
|
337
364
|
/**
|
|
338
365
|
* The record field a route param is matched on — ONE MAP, read by the local match
|
|
339
366
|
* (`routeParamValue`, below) and by the records service's record question (`match`,
|
package/src/website.js
CHANGED
|
@@ -12,7 +12,7 @@ import ObservableState from './observable-state.js'
|
|
|
12
12
|
import { normalizeSeo } from './seo.js'
|
|
13
13
|
import { siteAddress, pageUrl } from './site-address.js'
|
|
14
14
|
import { resolveDefaultLocale, localeLabel } from './locale-config.js'
|
|
15
|
-
import { isDynamicRoute, matchDynamicRoute, recordTitle, recordImage, routeBinding, routeParamName, parentRouteOf } from './route-match.js'
|
|
15
|
+
import { isDynamicRoute, matchDynamicRoute, recordTitle, recordImage, recordDescription, routeBinding, routeParamName, parentRouteOf } from './route-match.js'
|
|
16
16
|
import { resolveFetchConfigs, pageRouteQuery, recordPages } from './fetch-config.js'
|
|
17
17
|
import { declaredKeys } from './data-keys.js'
|
|
18
18
|
import { pageRecordConfig, planFor, runPlanSync } from './page-data.js'
|
|
@@ -682,9 +682,11 @@ export default class Website {
|
|
|
682
682
|
// read `title` alone, so a person record kept the template's title — `:slug`.
|
|
683
683
|
const title = recordTitle(currentItem)
|
|
684
684
|
if (title) pageData.title = title
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
685
|
+
// ⭐ And described by its text: `description`, else `excerpt` (`recordDescription`).
|
|
686
|
+
// ⛔ Until 2026-11-06 either was taken as it came, and a rich-text `description`
|
|
687
|
+
// described the page as `[object Object]`.
|
|
688
|
+
const description = recordDescription(currentItem)
|
|
689
|
+
if (description) pageData.description = description
|
|
688
690
|
// ⭐ And by its picture: a link to the page shows the record's image (`recordImage`).
|
|
689
691
|
// ⛔ Until 2026-10-05 it showed the page's or the site's `seo.image`, the same for
|
|
690
692
|
// every record.
|