Hello! I am trying to add schema to dynamic location pages through my cms. I have tried adding the code below but it does not seem to work. Can anyone give me any help please? Thank you.
import wixSeo from 'wix-seo';
$w.onReady(function () {
$w("#locations").onReady(() => {
let item = $w("#locations").getCurrentItem();
if (item && item.LBschema) {
try {
let schemaJson = JSON.parse(item.LBschema);
console.log("Schema Data:", schemaJson);
wixSeo.setStructuredData(schemaJson);
} catch (error) {
console.error("Invalid JSON in LBschema:", error);
}
} else {
console.warn("No schema found in LBschema field.");
}
});
});