Last active
September 19, 2022 12:21
-
-
Save KoenLeemans/ef01cf5df1a2d78bc702226d937b5159 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
// FAQ push | |
var faq_element = document.getElementById('faqs').getElementsByClassName('faq'); | |
var faq_array = []; | |
for (var i = 0; i < faq_element.length; i++) { | |
faq_array.push(faq_element[i]); | |
} | |
var faqs = []; | |
faq_array.forEach(function(element) { | |
faqs.push({ | |
"@type": "Question", | |
"name": element.getElementsByClassName('faq-question')[0].innerText, | |
"acceptedAnswer": { | |
"@type": "Answer", | |
"text": element.getElementsByClassName('faq-anwser')[0].innerHTML | |
} | |
}); | |
}); | |
var data = { | |
"@context": "https://schema.org", | |
"@type": "FAQPage", | |
"mainEntity": faqs | |
}; | |
var script = document.createElement('script'); | |
script.type = "application/ld+json"; | |
script.innerHTML = JSON.stringify(data); | |
document.getElementsByTagName('head')[0].appendChild(script); | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment