Skip to content

Commit 634fde5

Browse files
add suffix Html to headings
1 parent cd6517f commit 634fde5

File tree

6 files changed

+26
-22
lines changed

6 files changed

+26
-22
lines changed

dotcom-rendering/src/components/ProductElement.stories.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const ArticleElementComponent = getNestedArticleElement({
2121
const product = {
2222
_type: 'model.dotcomrendering.pageElements.ProductBlockElement',
2323
elementId: 'b1f6e8e2-3f3a-4f0c-8d1e-5f3e3e3e3e3e',
24-
primaryHeading: '<em>Best Kettle overall</em>',
25-
secondaryHeading: 'Bosch Sky Kettle',
24+
primaryHeadingHtml: '<em>Best Kettle overall</em>',
25+
secondaryHeadingHtml: 'Bosch Sky Kettle',
2626
brandName: 'Bosch',
2727
productName: 'Sky Kettle',
2828
image: productImage,
@@ -284,8 +284,8 @@ export const WithoutHeading = {
284284
args: {
285285
product: {
286286
...product,
287-
primaryHeading: '',
288-
secondaryHeading: '',
287+
primaryHeadingHtml: '',
288+
secondaryHeadingHtml: '',
289289
},
290290
},
291291
} satisfies Story;
@@ -303,8 +303,8 @@ export const NoSecondaryHeading = {
303303
args: {
304304
product: {
305305
...product,
306-
primaryHeading: '<em>Primary heading only</em>',
307-
secondaryHeading: '',
306+
primaryHeadingHtml: '<em>Primary heading only</em>',
307+
secondaryHeadingHtml: '',
308308
},
309309
},
310310
} satisfies Story;
@@ -313,8 +313,8 @@ export const NoPrimaryHeading = {
313313
args: {
314314
product: {
315315
...product,
316-
primaryHeading: '',
317-
secondaryHeading: 'Secondary heading only',
316+
primaryHeadingHtml: '',
317+
secondaryHeadingHtml: 'Secondary heading only',
318318
},
319319
},
320320
} satisfies Story;
@@ -366,8 +366,8 @@ export const WithoutFields = {
366366
product: {
367367
...product,
368368
image: undefined,
369-
primaryHeading: '',
370-
secondaryHeading: '',
369+
primaryHeadingHtml: '',
370+
secondaryHeadingHtml: '',
371371
brandName: '',
372372
productName: '',
373373
productCtas: [],

dotcom-rendering/src/components/ProductElement.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ const Content = ({
8888
shouldShowLeftColCard;
8989
const subheadingHtml = parseHtml(
9090
`<h2 id="${product.h2Id ?? product.elementId}">${
91-
product.primaryHeading ? `${product.primaryHeading}<br />` : ''
92-
} ${product.secondaryHeading || ''}</h2>`,
91+
product.primaryHeadingHtml
92+
? `${product.primaryHeadingHtml}<br />`
93+
: ''
94+
} ${product.secondaryHeadingHtml || ''}</h2>`,
9395
);
9496

9597
const isSubheading = subheadingHtml.textContent

dotcom-rendering/src/model/enhance-H2s.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { enhanceH2s } from './enhance-H2s';
44
const mockProductElement: FEElement = {
55
_type: 'model.dotcomrendering.pageElements.ProductBlockElement',
66
elementId: 'productMockId',
7-
primaryHeading: 'Primary Heading',
8-
secondaryHeading: 'Secondary Heading',
7+
primaryHeadingHtml: 'Primary Heading',
8+
secondaryHeadingHtml: 'Secondary Heading',
99
content: [],
1010
customAttributes: [],
1111
productCtas: [],
@@ -217,8 +217,8 @@ describe('Enhance h2 Embeds', () => {
217217
const expectedOutput: ProductBlockElement[] = [
218218
{
219219
...mockProductElement,
220-
primaryHeading: '<strong></strong>',
221-
secondaryHeading: '',
220+
primaryHeadingHtml: '<strong></strong>',
221+
secondaryHeadingHtml: '',
222222
h2Id: 'productMockId',
223223
},
224224
];

dotcom-rendering/src/model/enhance-H2s.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ export const enhanceH2s = (elements: FEElement[]): FEElement[] => {
8787
'model.dotcomrendering.pageElements.ProductBlockElement'
8888
) {
8989
const subheadingHtml = `<h2>${
90-
element.primaryHeading ? `${element.primaryHeading}</br>` : ''
91-
} ${element.secondaryHeading || ''}</h2>`;
90+
element.primaryHeadingHtml
91+
? `${element.primaryHeadingHtml}</br>`
92+
: ''
93+
} ${element.secondaryHeadingHtml || ''}</h2>`;
9294

9395
const h2Id = shouldUseElementId
9496
? element.elementId

dotcom-rendering/src/model/enhanceProductElement.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const productBlockElement: ProductBlockElement = {
2626
starRating: '5',
2727
productName: 'Sky Kettle',
2828
image: productImage,
29-
secondaryHeading: 'Best Kettle Overall',
30-
primaryHeading: 'Bosch Sky Kettle',
29+
secondaryHeadingHtml: 'Best Kettle Overall',
30+
primaryHeadingHtml: 'Bosch Sky Kettle',
3131
customAttributes: [
3232
{ name: 'What we love', value: 'It packs away pretty small' },
3333
{

dotcom-rendering/src/types/content.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ export interface ProductBlockElement {
476476
starRating: string;
477477
productName: string;
478478
image?: ProductImage;
479-
secondaryHeading: string;
480-
primaryHeading: string;
479+
secondaryHeadingHtml: string;
480+
primaryHeadingHtml: string;
481481
customAttributes: ProductCustomAttribute[];
482482
content: FEElement[];
483483
h2Id?: string;

0 commit comments

Comments
 (0)