const main = document.querySelector("main");

const icons = main.querySelectorAll("Icon");

icons.forEach((icon) => {
    let iconImage = icon.getAttribute("image");
    let link = icon.getAttribute("href");
    let title = icon.getAttribute("title");

    console.log(iconImage, link, title);

    if (iconImage) {
        let imageElement = document.createElement("img");
        
        imageElement.src = iconImage;
        imageElement.height = 64;
        imageElement.width = 64;

        icon.appendChild(imageElement);
    }

    if (link) {
        icon.addEventListener('click', (e) => {
            window.open(link, "_blank");
        });
    }

    if (title) {
        let titleElement = document.createElement("span");
        
        titleElement.textContent = title;
        icon.appendChild(titleElement);
    }
    
});