Make normal links in header more generic

This commit is contained in:
Tobias Berger 2021-10-05 12:54:19 +02:00
parent 6ddb78ef50
commit 9b9992a015

View file

@ -35,10 +35,7 @@
donate() { donate() {
console.log("donate"); console.log("donate");
}, },
discord() { discord: discordLink,
// No-Op
throw new Error("This function shouldn't have been called.");
},
notice() { notice() {
console.log("notice"); console.log("notice");
}, },
@ -52,17 +49,23 @@
<header id="header"> <header id="header">
<ul id="main-header-buttons"> <ul id="main-header-buttons">
{#each Object.entries(mainHeaderButtons) as [name, onClick]} {#each Object.entries(mainHeaderButtons) as [name, onClick]}
<li><a on:click={onClick} href={"javascript:;"}>{name}</a></li> <li>
{#if typeof onClick === "function"}
<a on:click={onClick} href={"javascript:;"}>{name}</a>
{:else if typeof onClick === "string"}
<a target="_blank" rel="noreferrer noopener" href={onClick}>{name}</a>
{/if}
</li>
{/each} {/each}
</ul> </ul>
<span>{title}</span> <span>{title}</span>
<ul id="other-header-buttons"> <ul id="other-header-buttons">
{#each Object.entries(otherHeaderButtons) as [name, onClick]} {#each Object.entries(otherHeaderButtons) as [name, onClick]}
<li> <li>
{#if name === "discord"} {#if typeof onClick === "function"}
<a href={discordLink} rel="noopener" target="_blank">{name}</a>
{:else}
<a on:click={onClick} href={"javascript:;"}>{name}</a> <a on:click={onClick} href={"javascript:;"}>{name}</a>
{:else if typeof onClick === "string"}
<a target="_blank" rel="noreferrer noopener" href={onClick}>{name}</a>
{/if} {/if}
</li> </li>
{/each} {/each}