document.addEventListener('DOMContentLoaded', function() {
function hideEmptyCollections() {
const collectionItems = document.querySelectorAll('.resource-list__item, .section-resource-list .card-wrapper');
collectionItems.forEach(item => {
const collectionCard = item.querySelector('.card-collection, .collection-card');
if (collectionCard) {
// Verificar si tiene productos (por texto o por estructura)
const hasNoProducts =
collectionCard.textContent.includes('No se encontraron productos') ||
collectionCard.textContent.includes('No products found') ||
collectionCard.querySelector('.placeholder') ||
!collectionCard.querySelector('img');
if (hasNoProducts) {
item.style.display = 'none';
}
}
});
}
// Ejecutar al cargar
hideEmptyCollections();
// Ejecutar también después de que cargue todo (por si usa lazy loading)
window.addEventListener('load', hideEmptyCollections);
// Observador por si la sección se actualiza dinámicamente
const observer = new MutationObserver(hideEmptyCollections);
observer.observe(document.body, { childList: true, subtree: true });
});