-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
31 lines (26 loc) · 1.18 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function fetchAndRenderSocialLinks() {
// Fetch the social links from the JSON file
fetch("social_links.json")
.then((response) => response.json())
.then((data) => {
const socialLinksSection = document.getElementById("social-links");
// Clear existing social links
socialLinksSection.innerHTML = '';
// Generate buttons for each social link
data.socialLinks.forEach((link) => {
const socialButton = document.createElement("a");
socialButton.href = link.url;
socialButton.target = "_blank";
socialButton.className = "btn btn-primary mr-2 mb-2";
socialButton.innerHTML = `${link.name} <i class="${link.icon}"></i>`;
socialLinksSection.appendChild(socialButton);
});
})
.catch((error) => {
console.error("Error loading social links:", error);
});
}
// Fetch and render social links initially
fetchAndRenderSocialLinks();
// Automatically refresh social links every 3 minutes (180,000 milliseconds)
setInterval(fetchAndRenderSocialLinks, 3 * 60 * 1000); // 3 minutes in milliseconds