From 1dd337abee55579d59e5a4a9f70bf6c66bb26cef Mon Sep 17 00:00:00 2001 From: Rob Court Date: Sun, 3 Jan 2021 23:27:27 +0000 Subject: [PATCH] ensuring meta is added --- components/VFBMain.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/VFBMain.js b/components/VFBMain.js index d97d4a258..e0dfac7f0 100644 --- a/components/VFBMain.js +++ b/components/VFBMain.js @@ -1278,8 +1278,18 @@ class VFBMain extends React.Component { document.querySelector('meta[property="og:title"]').setAttribute("content",this.responseXML.title); document.querySelector('meta[name="description"]').setAttribute("content",this.responseXML.body.innerText); document.querySelector('meta[property="og:description"]').setAttribute("content",this.responseXML.body.innerText); - if (document.getElementById('metaDesc') != null && this.responseXML.head != undefined && this.responseXML.head.getElementsByTagName('script') != undefined && this.responseXML.head.getElementsByTagName('script') != null && this.responseXML.head.getElementsByTagName('script')[1] != undefined) { - document.getElementById('metaDesc').innerHTML = this.responseXML.head.getElementsByTagName('script')[1].innerHTML; + if (document.getElementById('metaDesc') != null) { + if (this.responseXML.head != undefined && this.responseXML.head.getElementsByTagName('script') != undefined && this.responseXML.head.getElementsByTagName('script') != null && this.responseXML.head.getElementsByTagName('script')[1] != undefined) { + document.getElementById('metaDesc').innerHTML = this.responseXML.head.getElementsByTagName('script')[1].innerHTML; + } + } else { + if (this.responseXML.head != undefined && this.responseXML.head.getElementsByTagName('script') != undefined && this.responseXML.head.getElementsByTagName('script') != null && this.responseXML.head.getElementsByTagName('script')[1] != undefined) { + var script = document.createElement('script'); + script.type = 'application/ld+json'; + script.id = 'metaDesc'; + script.innerHTML = this.responseXML.head.getElementsByTagName('script')[1].innerHTML; + document.getElementsByTagName('head')[0].appendChild(script); + } } } } catch (err) {