{"version":3,"file":"CaseStudyAddLinkToFeed.Itg223O2.mjs","names":[],"sources":["https:/framerusercontent.com/modules/7i0gheaHLsPh7qZlJO8L/cxkL8lBSYN1BAh852dUN/CaseStudyAddLinkToFeed.js"],"sourcesContent":["// NOTE:\n// Becasue we are using the Case Studies CMS collection, but not the out of the box CMS single page templates, Framer cannot figure out how to genrerate links on the individual Case studies in the feed.\n// This code grabs all the Case Study elements onLoad and looks for a hidden element that contains the <SLUG> and builds the correct URL and applies it to the element.\n// Because we are using AJAX pagination, we also need to add a MutationObserver to the collection and listen for a content refresh. When that content refreshes we simply run the function above again and apply the links to the new elements.\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";export function addCaseStudyLinks(Component){return props=>{useEffect(()=>{applySlugLinks()// Apply links on first render\n;observeCaseStudyContainer()// Start watching for pagination updates\n;},[]);return /*#__PURE__*/_jsx(Component,{...props});};}// Function to apply links to all \"Case Study Element\" items\nfunction applySlugLinks(){requestAnimationFrame(()=>{const caseStudyElements=document.querySelectorAll('[data-framer-name=\"Case Study Element\"]');caseStudyElements.forEach(element=>{if(element.getAttribute(\"data-linked\"))return;// Prevent duplicate processing\nconst slugContainer=element.querySelector('[data-framer-name=\"Slug\"]');let slug=slugContainer?.querySelector(\"p\")?.textContent?.trim()||\"\";if(slug){const href=`/knowledge/case-studies/${slug}`;if(element.tagName.toLowerCase()===\"a\"){element.setAttribute(\"href\",href);}else{element.style.cursor=\"pointer\";element.addEventListener(\"click\",()=>window.location.href=href);}element.setAttribute(\"data-linked\",\"true\")// Mark as processed\n;}});});}// MutationObserver to watch for updates inside `CSContainer`\nfunction observeCaseStudyContainer(){const caseStudiesContainer=document.querySelector('[data-framer-name=\"CSContainer\"]');if(!caseStudiesContainer)return;const observer=new MutationObserver(mutations=>{let shouldApplyLinks=false;mutations.forEach(mutation=>{if(mutation.type===\"childList\"){shouldApplyLinks=true// A child was added or removed\n;}});if(shouldApplyLinks){// console.log(\"Case study content updated, reapplying links...\")\napplySlugLinks();}});observer.observe(caseStudiesContainer,{childList:true,subtree:true});}\nexport const __FramerMetadata__ = {\"exports\":{\"addCaseStudyLinks\":{\"type\":\"reactHoc\",\"name\":\"addCaseStudyLinks\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CaseStudyAddLinkToFeed.map"],"mappings":"mMAIwE,SAAgB,EAAkB,EAAU,CAAC,MAAO,KAAQ,MAAc,CAAC,GAAgB,CAClK,GAA2B,EACzB,EAAE,CAAC,CAAqB,EAAK,EAAU,CAAC,GAAG,EAAM,CAAC,EACrD,SAAS,GAAgB,CAAC,0BAA0B,CAAyB,SAAS,iBAAiB,0CAA0C,CAAmB,QAAQ,GAAS,CAAC,GAAG,EAAQ,aAAa,cAAc,CAAC,OACtJ,IAAI,EAAvD,EAAQ,cAAc,4BAA4B,EAAyB,cAAc,IAAI,EAAE,aAAa,MAAM,EAAE,GAAG,GAAG,EAAK,CAAC,IAAM,EAAK,2BAA2B,IAAU,EAAQ,QAAQ,aAAa,GAAG,IAAK,EAAQ,aAAa,OAAO,EAAK,EAAO,EAAQ,MAAM,OAAO,UAAU,EAAQ,iBAAiB,YAAY,EAAO,SAAS,KAAK,EAAK,EAAE,EAAQ,aAAa,cAAc,OAAO,GACvZ,EAAG,CACP,SAAS,GAA2B,CAAC,IAAM,EAAqB,SAAS,cAAc,mCAAmC,CAAK,GAA2C,IAAI,iBAAiB,GAAW,CAAC,IAAI,EAAiB,GAAM,EAAU,QAAQ,GAAU,CAAI,EAAS,OAAO,cAAa,EAAiB,KAChT,CAAI,GACR,GAAgB,EAAI,CAAU,QAAQ,EAAqB,CAAC,UAAU,GAAK,QAAQ,GAAK,CAAC,sBAR9C,IAA6B"}