Skip to content

Commit

Permalink
Fix heading test if h1 tag is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
juffalow committed Jul 26, 2024
1 parent 163d65f commit 45568ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/functions/getHeading.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { URL } from 'url';
import getObject from './getObject';

const getHeading = (result: any): string | string[] => {
Expand Down
14 changes: 11 additions & 3 deletions src/seo/Heading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ class Heading extends Test {
private checkHeading(title: string | string[]): Array<Result> {
const results = [];

if (typeof title === 'undefined') {
return [{
status: 'ERROR',
title: 'H1 tag',
description: 'HTML should contain H1 tag.',
}];
}

results.push({
status: typeof title !== undefined && title.length > 0 ? 'SUCCESS' : 'WARNING',
title: 'H1 tag',
Expand All @@ -33,13 +41,13 @@ class Heading extends Test {
results.push({
status: Array.isArray(title) ? 'ERROR' : 'SUCCESS',
title: 'Duplicate H1 tag',
description: `HTML should contain just one title tag.`,
description: `HTML should contain just one H1 tag.`,
});

results.push({
status: title.length <= 60 ? 'SUCCESS' : 'WARNING',
title: 'Title length',
description: `Title length should be under 60 characters and it is ${title.length}.`,
title: 'H1 length',
description: `H1 length should be under 60 characters and it is ${title.length}.`,
});

return results;
Expand Down

0 comments on commit 45568ae

Please sign in to comment.