add discord and dynamic icons

This commit is contained in:
2021-04-21 13:31:33 +02:00
parent cc5c6cd595
commit 800edd75c7
10 changed files with 62 additions and 9 deletions

View File

@@ -1,17 +1,37 @@
<script>
import { onMount } from 'svelte'
export let icon
$: src = `/icons/${icon}.svg`
let html = null
onMount(async () => {
console.log(src)
html = await fetch(src).then((res) => res.text())
})
</script>
<img {...$$restProps} src="/icons/{icon}.svg" alt={icon} />
{#if html === null}
<img {...$$restProps} {src} alt={icon} />
{:else}
<span {...$$restProps}>
{@html html}
</span>
{/if}
<style>
span,
img {
display: inline-block;
width: 1em;
height: 1em;
contain: strict;
fill: currentcolor;
/* fill: currentcolor; */
box-sizing: content-box;
transform: translateY(0.2em);
}
span > :global(svg) {
display: block;
}
</style>

View File

@@ -7,6 +7,11 @@
{
href: 'mailto:hi@nicco.io',
name: 'Say hi@nicco.io',
icon: 'mail-outline',
},
{
href: 'https://discord.gg/wS7RpYTYd2',
name: 'Chat on Discord',
icon: 'chatbubbles-outline',
},
{