Skip to content

Commit 0c700fd

Browse files
authored
Merge pull request #13743 from guardian/show-toc-when-there-is-at-least-1-heading
Show ToC when there is at least 1 heading
2 parents fed6381 + ad3583c commit 0c700fd

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,15 @@ describe('Enhance Table of Contents', () => {
6060
]);
6161
});
6262

63-
it('will not return a toc if the are fewer than 3 h2s', () => {
63+
it('will not return a toc if there are no h2s', () => {
6464
const input: Block[] = [
6565
{
6666
...blockMetaData,
6767
elements: [
6868
{
69-
_type: 'model.dotcomrendering.pageElements.SubheadingBlockElement',
70-
elementId: 'h2One',
71-
html: '<h2>This is the h2 text</h2>',
72-
},
73-
{
74-
_type: 'model.dotcomrendering.pageElements.SubheadingBlockElement',
75-
elementId: 'h2Two',
76-
html: '<h2>This is the h2 text</h2>',
69+
_type: 'model.dotcomrendering.pageElements.TextBlockElement',
70+
elementId: 'text',
71+
html: 'Text',
7772
},
7873
],
7974
},

dotcom-rendering/src/model/enhanceTableOfContents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,5 @@ export const enhanceTableOfContents = (
112112
}
113113
}
114114

115-
return tocItems.length >= 3 ? tocItems : undefined;
115+
return tocItems.length >= 1 ? tocItems : undefined;
116116
};

0 commit comments

Comments
 (0)