diff --git a/src/checks/og-tags.check.ts b/src/checks/og-tags.check.ts
index 9c14f97..4632650 100644
--- a/src/checks/og-tags.check.ts
+++ b/src/checks/og-tags.check.ts
@@ -1,10 +1,10 @@
-import { IChecker, IRecommendation, ICheckerContext } from '../interfaces';
+import { IChecker, ICheckerContext, IRecommendation } from '../interfaces';
const documentation = 'https://docs.prerender.io/docs/open-graph';
export const check_og_tags: IChecker = ({ $, raw_html }: ICheckerContext) => {
const recommendations: IRecommendation[] = [];
- let score_delta = 4.0;
+ let score_delta = 0;
// required fields
const ogTitle = $('meta[property="og:title"]').attr('content');
@@ -12,7 +12,9 @@ export const check_og_tags: IChecker = ({ $, raw_html }: ICheckerContext) => {
const ogImage = $('meta[property="og:image"]').attr('content');
const ogURL = $('meta[property="og:url"]').attr('content');
- const penalty = -1;
+ const penalty = -2;
+ const optionalPenalty = -1;
+
if (!ogTitle) {
score_delta += penalty;
@@ -21,6 +23,8 @@ export const check_og_tags: IChecker = ({ $, raw_html }: ICheckerContext) => {
documentation: documentation,
scoreDelta: penalty,
});
+ } else {
+ score_delta += Math.abs(penalty);
}
if (!ogType) {
@@ -31,6 +35,8 @@ export const check_og_tags: IChecker = ({ $, raw_html }: ICheckerContext) => {
documentation: documentation,
scoreDelta: penalty,
});
+ } else {
+ score_delta += Math.abs(penalty);
}
if (!ogImage) {
@@ -41,6 +47,8 @@ export const check_og_tags: IChecker = ({ $, raw_html }: ICheckerContext) => {
documentation: documentation,
scoreDelta: penalty,
});
+ } else {
+ score_delta += Math.abs(penalty);
}
if (!ogURL) {
@@ -51,6 +59,23 @@ export const check_og_tags: IChecker = ({ $, raw_html }: ICheckerContext) => {
documentation: documentation,
scoreDelta: penalty,
});
+ } else {
+ score_delta += Math.abs(penalty);
+ }
+
+ // optional fields
+ const ogDescription = $('meta[property="og:description"]').attr('content');
+
+ if (!ogDescription) {
+ score_delta -= optionalPenalty;
+
+ recommendations.push({
+ description: 'Missing og:description meta tag',
+ documentation: documentation,
+ scoreDelta: penalty,
+ });
+ } else {
+ score_delta += Math.abs(optionalPenalty) * 2;
}
return {
diff --git a/src/checks/og-tags.test.ts b/src/checks/og-tags.test.ts
index 3fd1bd5..a6be865 100644
--- a/src/checks/og-tags.test.ts
+++ b/src/checks/og-tags.test.ts
@@ -10,16 +10,17 @@ describe('Og Tags Test', () => {
+