@datagouv/components-next 1.4.1-dev.1369.ge90e64f3 → 1.4.1-dev.1371.ge3406487

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.
@@ -30461,10 +30461,10 @@ var ej = mO.RenderStrategy, tj = I({
30461
30461
  ]))], 64));
30462
30462
  }
30463
30463
  }), bj = 200, xj = 200, Sj = 200;
30464
- function Cj({ description: e, descriptionShort: t }) {
30465
- if (t?.trim()) return t;
30464
+ function Cj({ description: e, description_short: t }) {
30465
+ if (t?.trim()) return t.replace(/\s+/g, " ").trim();
30466
30466
  if (e?.trim()) {
30467
- let t = CD(e).trim();
30467
+ let t = CD(e).replace(/\s+/g, " ").trim();
30468
30468
  return t.length > 200 ? `${t.substring(0, 199)}…` : t;
30469
30469
  }
30470
30470
  return "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datagouv/components-next",
3
- "version": "1.4.1-dev.1369.ge90e64f3",
3
+ "version": "1.4.1-dev.1371.ge3406487",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "engines": {
@@ -13,17 +13,18 @@ export const AI_SUGGESTION_MIN_DESCRIPTION_LENGTH = 200 // min `description` len
13
13
  * Returns the short description to display.
14
14
  * If description_short is provided, it is used.
15
15
  * Otherwise, the first DESCRIPTION_SHORT_MAX_LENGTH characters of description are used.
16
+ * Whitespace runs are collapsed to keep the output single-line: it feeds HTML meta tags.
16
17
  */
17
- export function getDescriptionShort({ description, descriptionShort }: {
18
+ export function getDescriptionShort({ description, description_short: descriptionShort }: {
18
19
  description: string | null | undefined
19
- descriptionShort?: string | null | undefined
20
- }) {
20
+ description_short?: string | null | undefined
21
+ }): string {
21
22
  if (descriptionShort?.trim()) {
22
- return descriptionShort
23
+ return descriptionShort.replace(/\s+/g, ' ').trim()
23
24
  }
24
25
  if (description?.trim()) {
25
26
  // description field is a markdown field that may contain HTML tags, so we should trim it
26
- const plainText = removeMarkdownSync(description).trim()
27
+ const plainText = removeMarkdownSync(description).replace(/\s+/g, ' ').trim()
27
28
  if (plainText.length > DESCRIPTION_SHORT_MAX_LENGTH) {
28
29
  return `${plainText.substring(0, DESCRIPTION_SHORT_MAX_LENGTH - 1)}…`
29
30
  }