diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/socials.json | 10 | ||||
| -rw-r--r-- | src/routes/+page.svelte | 12 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/lib/socials.json b/src/lib/socials.json index 208a115..16ebb5f 100644 --- a/src/lib/socials.json +++ b/src/lib/socials.json @@ -2,23 +2,23 @@ "socials": [ { "link": "https://github.com/pml68", - "icon": "Github" + "iconIndex": 0 }, { "link": "https://dev.to/pml68", - "icon": "Dev" + "iconIndex": 1 }, { "link": "https://steamcommunity.com/id/nigmaballs", - "icon": "Steam" + "iconIndex": 2 }, { "link": "https://t.me/pml68_1", - "icon": "Telegram" + "iconIndex": 3 }, { "link": "mailto:contact@pml68.me", - "icon": "Envelope" + "iconIndex": 4 } ] } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index c6d0eb7..6c403ee 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -9,15 +9,17 @@ import TelegramIcon from '$lib/assets/telegram.svg?src' import EnvelopeIcon from '$lib/assets/envelope.svg?src' + const icons: string[] = [SteamIcon, GithubIcon, DevIcon, TelegramIcon, EnvelopeIcon] + type Social = { link: string, - icon: string + iconIndex: number } const socialsList: Social[] = socials - const insertIcon: Function = (element: HTMLElement, icon: string) => { - element.innerHTML = eval(`${icon}Icon`) + const insertIcon: Function = (element: HTMLElement, iconIndex: string) => { + element.innerHTML = icons[iconIndex] } </script> @@ -29,8 +31,8 @@ <h1>pml68</h1> <p>Just your average IT student</p> <div class="socials"> - {#each socialsList as {link, icon}} - <a use:insertIcon={icon} href={link} target="_blank" class="icon"></a> + {#each socialsList as {link, iconIndex}} + <a use:insertIcon={iconIndex} href={link} target="_blank" class="icon"></a> {/each} </div> <div class="projects"> |
