-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (37 loc) · 1.27 KB
/
script.js
File metadata and controls
46 lines (37 loc) · 1.27 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
const menuLinks = [
{ text: 'Блог', link: './blog.html' },
{ text: 'Проекты', link: './projects.html' },
{ text: 'Хобби', link: './hobby.html' },
{ text: 'Резюме', link: './resume.html' }
];
const contactsLinks = [
{ link: 'https://vk.com/goose_fn', iconClass: 'bi bi-chat-fill' },
{ link: 'https://t.me/goose_FN', iconClass: 'bi bi-telegram' },
{ link: 'https://github.com/gooseFn', iconClass: 'bi bi-github' }
];
function getElement(linkData, isContacts = false) {
let listItem = document.createElement('li');
let link = document.createElement('a');
link.href = linkData.link;
if (isContacts) {
link.target = '_blank';
let icon = document.createElement('i');
icon.className = linkData.iconClass;
link.appendChild(icon);
} else {
link.textContent = linkData.text;
}
listItem.appendChild(link);
return listItem;
}
function renderLinks(containerId, linksType) {
const navContainer = document.getElementById(containerId);
if (!navContainer) return;
const isContacts = linksType === 'contacts';
let links = isContacts ? contactsLinks : menuLinks;
links.forEach(link => {
navContainer.appendChild(getElement(link, isContacts));
});
}
renderLinks('footer', 'contacts');
renderLinks('header', 'menu');