// Shop loader for shop.html and product.html (async () => { const DATA = 'assets/products.json'; async function fetchProducts(){ try { const res = await fetch(DATA, {cache: "no-store"}); if(!res.ok) throw new Error('Failed to load products'); return await res.json(); } catch (err) { console.error(err); return []; } } const products = await fetchProducts(); const grid = document.getElementById('product-grid'); const productPage = document.getElementById('product-page'); // SHOP GRID if (grid) { grid.innerHTML = ''; if(products.length === 0){ grid.innerHTML = '
No products found.
'; } else { for(const p of products){ const card = document.createElement('div'); card.className = 'product-card'; card.innerHTML = `
${p.thumbAlt || 'Preview'}

${p.title}

${p.short}

${p.price}
${p.type||'Digital'}
Buy on Roblox
`; grid.appendChild(card); } } } // PRODUCT DETAIL PAGE if (productPage) { const params = new URLSearchParams(location.search); const id = params.get('id'); const product = products.find(p => p.id === id); if (!product) { productPage.innerHTML = `

Product not found. Back to shop

`; return; } productPage.innerHTML = `
${product.thumbAlt || 'Preview'}

${product.title}

${product.long}

`; } })();