1class PlpRelatedLinks extends HTMLElement{constructor(){super(),this.handleCollection=this.dataset.handleCollection,this.maxLinks=parseInt(this.dataset.maxLinks||"0",10)}connectedCallback(){this.fetchData()}async fetchData(){if(this.handleCollection)try{const response=await fetch(`https://api.wordlift.io/data/https/www.readers.com/collections/${this.handleCollection}`);if(!response.ok)throw new Error(`HTTP Error: ${response.status}`);const collectionPage=(await response.json()).find(item=>{const type=item["@type"];return Array.isArray(type)?type.some(t=>t.includes("CollectionPage")):type&&type.includes("CollectionPage")});let relatedLinks=[];if(collectionPage){const categoryLinks=collectionPage["eyewear:categoryRelatedLinks"];Array.isArray(categoryLinks)&&categoryLinks.length>0&&(relatedLinks=categoryLinks.sort((a,b)=>{const orderA=parseInt(a["eyewear:categoryRelatedLinkOrder"]||"0",10),orderB=parseInt(b["eyewear:categoryRelatedLinkOrder"]||"0",10);return orderA-orderB}).map(entry=>({url:entry["eyewear:categoryRelatedLinkUrl"]||"",name:(entry["eyewear:categoryRelatedLinkName"]||"").trim()})).filter(entry=>entry.url)),relatedLinks.length===0&&Array.isArray(collectionPage.relatedLink)&&(relatedLinks=collectionPage.relatedLink.map(url=>({url,name:""})))}if(relatedLinks.length>0){const linksToRender=this.maxLinks>0?relatedLinks.slice(0,this.maxLinks):relatedLinks;this.renderLinks(linksToRender)}this.removeAttribute("hidden")}catch(error){this.removeAttribute("hidden"),console.error("PlpRelatedLinks fetch error:",error)}}getLabelFromUrl(url){try{return(new URL(url).pathname.split("/").filter(Boolean).pop()||"").replace(/-/g," ").replace(/\b\w/g,char=>char.toUpperCase())}catch{return url}}renderLinks(links){const list=this.querySelector(".plp-related-links__list");list&&links.forEach(linkData=>{const linkUrl=linkData.url,linkName=linkData.name;let href=linkUrl;try{href=new URL(linkUrl).pathname}catch{}const label=linkName||this.getLabelFromUrl(linkUrl),li=document.createElement("li");li.className="tw-w-fit tw-border-[.1rem] tw-border-[#45423d80] hover:tw-border-dark-grey tw-rounded-t-[2rem] tw-rounded-tr-[0] tw-rounded-b-[1.6rem] tw-rounded-l-[2rem] tw-group hover:tw-outline hover:tw-outline-1";const a=document.createElement("a");a.href=href,a.className="tw-flex tw-gap-[1rem] tw-text-[1.4rem] tw-leading-[1.4rem] tw-text-[#45423D] tw-py-[.8rem] tw-px-[1.2rem] tw-whitespace-nowrap";const span=document.createElement("span");span.className="tw-whitespace-nowrap tw-text-ellipsis tw-overflow-hidden",span.textContent=label,a.appendChild(span),li.appendChild(a),list.appendChild(li)})}}customElements.get("plp-related-links")||customElements.define("plp-related-links",PlpRelatedLinks); 2//# sourceMappingURL=/cdn/shop/t/236/assets/plp-related-links.js.map?v=168904616210480513661783515797
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.