vakno
vakno
CDCloudflare Developers
Created by vakno on 1/15/2024 in #workers-help
I want to implement schema markup for FaqElement via cloudflare
Hey i am new to cloudflare and workers. I want to implement schema markup for FaqElement via cloudflare worker. I made a worker that has hardcoded script like this.
const schemaMarkup = {
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is Lorem Ipsum?",
"acceptedAnswer": {
"@type": "Answer",
"text": "answer"
}
},
{
"@type": "Question",
"name": "Why do we use it?",
"acceptedAnswer": {
"@type": "Answer",
"text": "answer 2"
}
},
{
"@type": "Question",
"name": "Where does it come from?",
"acceptedAnswer": {
"@type": "Answer",
"text": "answer 3"
}
}
// Add more FAQ items as needed
]
};
const schemaMarkup = {
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is Lorem Ipsum?",
"acceptedAnswer": {
"@type": "Answer",
"text": "answer"
}
},
{
"@type": "Question",
"name": "Why do we use it?",
"acceptedAnswer": {
"@type": "Answer",
"text": "answer 2"
}
},
{
"@type": "Question",
"name": "Where does it come from?",
"acceptedAnswer": {
"@type": "Answer",
"text": "answer 3"
}
}
// Add more FAQ items as needed
]
};
My question is if i can tell worker to set answers and questions dynamically from HTML (from class name for example), i cant seem to make it work with HTMLRewriter class.
3 replies