{"version":3,"file":"JsonSchemaFaq.Bk-RiG83.mjs","names":["renderToString"],"sources":["https:/framerusercontent.com/modules/DHG2W4p8AORGMUaUgNCa/TYgrLraMyJyC6KiPsODO/JsonSchemaFaq.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect}from\"react\";import{renderToString}from\"react-dom/server\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const useStore=createStore({faqItems:[]});// This should be added to the CMS item component\n// It expects the element it wraps to have two fields: `question`, and `content`\n//\n// Note: This does not de-duplicate content.\nexport function withCaptureFAQ(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();useEffect(()=>{if(props.question&&props.content){// console.log(\"capturing\", props.question, props.answer)\nsetStore(current=>({faqItems:[...current.faqItems,{question:props.question,answer:renderToString(props.content)}]}));}},[props.question,props.content]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}// This code override should be added to the page component\nexport function InjectJsonSchemaFaq(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const[store,setStore]=useStore();useEffect(()=>{const faqs=store&&store.faqItems;if(faqs){if(!faqs||faqs.length===0)return;// Build JSON-LD structure\nconst jsonLd={\"@context\":\"https://schema.org\",\"@type\":\"FAQPage\",mainEntity:faqs.map(faq=>({\"@type\":\"Question\",name:faq.question,acceptedAnswer:{\"@type\":\"Answer\",text:faq.answer}}))};const script=document.createElement(\"script\");script.type=\"application/ld+json\";script.id=\"faq-jsonld\"// useful so you can replace it later\n;script.text=JSON.stringify(jsonLd);const existing=document.querySelector(\"[id=faq-jsonld]\");// we have to do this because the FAQs will get added to the store in batches\n// and the useEffect hook will run on every update\nif(existing){document.body.replaceChild(script,existing);}else{document.body.appendChild(script);}}},[store.faqItems])// run on page mount\n;return /*#__PURE__*/_jsx(Component,{ref:ref,...props});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withCaptureFAQ\":{\"type\":\"reactHoc\",\"name\":\"withCaptureFAQ\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"InjectJsonSchemaFaq\":{\"type\":\"reactHoc\",\"name\":\"InjectJsonSchemaFaq\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./JsonSchemaFaq.map"],"mappings":"mOAIA,SAAgB,EAAe,EAAU,CAAC,OAAoB,GAAY,EAAM,IAAM,CAAC,GAAK,CAAC,EAAM,GAAU,GAAU,CACiC,OADhC,MAAc,CAAI,EAAM,UAAU,EAAM,SAChK,EAAS,IAAU,CAAC,SAAS,CAAC,GAAG,EAAQ,SAAS,CAAC,SAAS,EAAM,SAAS,OAAOA,EAAe,EAAM,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAI,CAAC,EAAM,SAAS,EAAM,QAAQ,CAAC,CAAqB,EAAK,EAAU,CAAK,MAAI,GAAG,EAAM,CAAC,EAAG,CACjN,SAAgB,EAAoB,EAAU,CAAC,OAAoB,GAAY,EAAM,IAAM,CAAC,GAAK,CAAC,EAAM,GAAU,GAAU,CAK3H,OAL4H,MAAc,CAAC,IAAM,EAAK,GAAO,EAAM,SAAS,GAAG,EAAK,CAAC,GAAG,CAAC,GAAM,EAAK,SAAS,EAAE,OAChN,IAAM,EAAO,CAAC,WAAW,qBAAqB,QAAQ,UAAU,WAAW,EAAK,IAAI,IAAM,CAAC,QAAQ,WAAW,KAAK,EAAI,SAAS,eAAe,CAAC,QAAQ,SAAS,KAAK,EAAI,OAAO,CAAC,EAAE,CAAC,CAAO,EAAO,SAAS,cAAc,SAAS,CAAC,EAAO,KAAK,sBAAsB,EAAO,GAAG,aAC/Q,EAAO,KAAK,KAAK,UAAU,EAAO,CAAC,IAAM,EAAS,SAAS,cAAc,kBAAkB,CAEzF,EAAU,SAAS,KAAK,aAAa,EAAO,EAAS,CAAO,SAAS,KAAK,YAAY,EAAO,GAAK,CAAC,EAAM,SAAS,CAAC,CACjG,EAAK,EAAU,CAAK,MAAI,GAAG,EAAM,CAAC,EAAG,oBAXf,IAAwC,IAA6C,IAAqE,CAAM,EAAS,EAAY,CAAC,SAAS,EAAE,CAAC,CAAC"}