-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
78 lines (65 loc) · 2.77 KB
/
script.js
File metadata and controls
78 lines (65 loc) · 2.77 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
document.addEventListener('DOMContentLoaded', async () => {
try {
const response = await fetch('data.json');
const data = await response.json();
const linksSection = document.getElementById('links');
const socialsSection = document.getElementById('socials');
data.sections.forEach(section => {
// Handle Socials separately (icons)
if (section.header === "Socials") {
const ul = document.createElement('ul');
ul.className = 'socials-ul';
section.links.forEach(link => {
const li = document.createElement('li');
li.className = 'socials-li';
const a = document.createElement('a');
a.id = link.id;
a.className = 'socials-a';
a.href = link.url;
a.target = '_blank';
const img = document.createElement('img');
img.className = 'socials-img';
img.width = 50;
img.height = 50;
img.src = link.icon;
img.alt = link.name;
a.appendChild(img);
li.appendChild(a);
ul.appendChild(li);
});
socialsSection.appendChild(ul);
}
// Handle other link sections
else {
const container = document.createElement('div');
container.className = 'link-container';
// Portfolio section has no header
if (section.header !== "Portfolio") {
const header = document.createElement('div');
header.className = 'link-header';
const h2 = document.createElement('h2');
h2.textContent = section.header;
header.appendChild(h2);
container.appendChild(header);
}
const list = document.createElement('div');
list.className = 'link-list';
section.links.forEach(link => {
const a = document.createElement('a');
a.id = link.id;
a.className = 'link-a';
a.href = link.url;
a.target = '_blank';
a.textContent = link.name;
list.appendChild(a);
});
container.appendChild(list);
linksSection.appendChild(container);
}
});
// Set copyright year
document.getElementById('copyright').textContent = new Date().getFullYear();
} catch (err) {
console.error('Error loading data.json:', err);
}
});