From fa691d90c084add84a1870c23c22207f729a2188 Mon Sep 17 00:00:00 2001 From: ppoffice Date: Fri, 17 Apr 2020 12:29:38 -0400 Subject: [PATCH] fix(layout): nullable open graph & structure data --- layout/common/head.jsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/layout/common/head.jsx b/layout/common/head.jsx index ab509c9..0b950c9 100644 --- a/layout/common/head.jsx +++ b/layout/common/head.jsx @@ -89,14 +89,16 @@ module.exports = class extends Component { } let openGraphImages = images; - if ((Array.isArray(open_graph.image) && open_graph.image.length > 0) || typeof open_graph.image === 'string') { + if ((typeof open_graph === 'object' && open_graph !== null) + && ((Array.isArray(open_graph.image) && open_graph.image.length > 0) || typeof open_graph.image === 'string')) { openGraphImages = open_graph.image; } else if ((Array.isArray(page.photos) && page.photos.length > 0) || typeof page.photos === 'string') { openGraphImages = page.photos; } let structuredImages = images; - if ((Array.isArray(structured_data.image) && structured_data.image.length > 0) || typeof structured_data.image === 'string') { + if ((typeof structured_data === 'object' && structured_data !== null) + && ((Array.isArray(structured_data.image) && structured_data.image.length > 0) || typeof structured_data.image === 'string')) { structuredImages = structured_data.image; } else if ((Array.isArray(page.photos) && page.photos.length > 0) || typeof page.photos === 'string') { structuredImages = page.photos; @@ -110,7 +112,7 @@ module.exports = class extends Component { {getPageTitle(page, config.title, helper)} - {typeof open_graph === 'object' ? : null} - {typeof structured_data === 'object' ?