From ff33edc7cfbe53f58056916ad876d841e43a0514 Mon Sep 17 00:00:00 2001 From: brulijam Date: Thu, 5 Sep 2024 14:02:50 +0200 Subject: [PATCH] made footer links customizable --- src/content/links.json | 25 +++++++++++++++++++++ src/css/main.css | 15 ++++++++++--- src/index.html | 8 +------ src/js/links.js | 50 +++++++++++++++++++++++++++++------------- 4 files changed, 73 insertions(+), 25 deletions(-) diff --git a/src/content/links.json b/src/content/links.json index 61e8706..490af00 100644 --- a/src/content/links.json +++ b/src/content/links.json @@ -125,6 +125,31 @@ "href": "https://youtube.com/@brulijam", "icon": "https://simpleicons.org/icons/youtube.svg", "group": 2 + }, + { + "name": "source code", + "href": "https://git.brulijam.com/brulijam/introduction-website", + "group": "footer" + }, + { + "name": "links json", + "href": "content/links.json", + "group": "footer" + }, + { + "name": "status", + "href": "https://status.brulijam.com/status/brulijam", + "group": "footer" + }, + { + "name": "files", + "href": "https://brulijam.com/files", + "group": "footer" + }, + { + "name": "music", + "href": "https://brulijam.com/music", + "group": "footer" } ], "groupNames": { diff --git a/src/css/main.css b/src/css/main.css index 0a0d114..95b77f4 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -82,15 +82,24 @@ h2 { } } +.text-link::before { + content: "["; +} + +.text-link::after { + content: "]"; +} + .text-link { color: var(--secondary-color); - text-decoration: underline solid var(--secondary-color2) 1px; + text-decoration: none; position: relative; - padding: 0 2px; + padding: 5px; + white-space: nowrap; + display: inline-block; } .text-link:hover { - text-decoration: underline solid var(--secondary-color) 1px; filter: drop-shadow(0 0 5px var(--secondary-color2)) brightness(1.02); top: -2px; } diff --git a/src/index.html b/src/index.html index 6d36b59..b71ea65 100644 --- a/src/index.html +++ b/src/index.html @@ -61,13 +61,7 @@
- + \ No newline at end of file diff --git a/src/js/links.js b/src/js/links.js index 823739a..49187c5 100644 --- a/src/js/links.js +++ b/src/js/links.js @@ -13,31 +13,51 @@ function createLinkDiv(link) { return linkDiv; } +function createFooterLink(link) { + const footerLink = document.createElement('a'); + footerLink.className = 'text-link'; + footerLink.href = link.href; + footerLink.target = '_blank'; + footerLink.textContent = link.name; + return footerLink; +} + function createGroups(linksData, groupNames) { const container = document.querySelector('.links'); + const footer = document.querySelector('footer'); const groups = [...new Set(linksData.map(link => link.group))].sort((a, b) => a - b); groups.forEach((group, index) => { - const groupContainer = document.createElement('div'); - groupContainer.className = 'linkGroup'; + if (group === "footer") { + linksData + .filter(link => link.group === "footer") + .forEach(link => { + const footerLink = createFooterLink(link); + footer.appendChild(footerLink); + }); + } else { + // Handle regular links + const groupContainer = document.createElement('div'); + groupContainer.className = 'linkGroup'; - const groupHeader = document.createElement('h2'); - groupHeader.textContent = `${groupNames[group]}`; - groupContainer.appendChild(groupHeader); + const groupHeader = document.createElement('h2'); + groupHeader.textContent = `${groupNames[group]}`; + groupContainer.appendChild(groupHeader); - linksData - .filter(link => link.group === group) - .forEach(link => { - const linkElement = createLinkDiv(link); - groupContainer.appendChild(linkElement); - }); + linksData + .filter(link => link.group === group) + .forEach(link => { + const linkElement = createLinkDiv(link); + groupContainer.appendChild(linkElement); + }); - container.appendChild(groupContainer); + container.appendChild(groupContainer); - if (index < groups.length - 1) { - const br = document.createElement('br'); - container.appendChild(br); + if (index < groups.length - 1) { + const br = document.createElement('br'); + container.appendChild(br); + } } }); }