2023-03-26 00:07:51 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import { Icon } from "sveltestrap";
|
|
|
|
|
|
|
|
export let link: string;
|
|
|
|
|
|
|
|
let displayLink: string;
|
|
|
|
$: displayLink = prettifyLink(link);
|
|
|
|
|
2023-03-27 04:43:39 +02:00
|
|
|
let isLink = true;
|
|
|
|
$: isLink = link.startsWith("http://") || link.startsWith("https://");
|
|
|
|
|
2023-03-26 00:07:51 +01:00
|
|
|
const prettifyLink = (raw: string) => {
|
|
|
|
let out = raw;
|
|
|
|
if (raw.startsWith("https://")) out = raw.substring("https://".length);
|
|
|
|
else if (raw.startsWith("http://")) out = raw.substring("http://".length);
|
|
|
|
|
|
|
|
if (raw.endsWith("/")) out = raw.substring(0, raw.length - 1);
|
|
|
|
|
|
|
|
return out;
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
2023-03-27 04:43:39 +02:00
|
|
|
{#if isLink}
|
2023-03-27 23:46:06 +02:00
|
|
|
<a href={link} class="text-decoration-none">
|
|
|
|
<li class="py-2 py-lg-0">
|
|
|
|
<Icon name="globe" aria-hidden class="text-body" />
|
|
|
|
<span class="text-decoration-underline">{displayLink}</span>
|
|
|
|
</li>
|
|
|
|
</a>
|
2023-03-27 04:43:39 +02:00
|
|
|
{:else}
|
2023-03-27 23:46:06 +02:00
|
|
|
<li class="py-2 py-lg-0">
|
|
|
|
<Icon name="globe" aria-hidden />
|
|
|
|
<span>{displayLink}</span>
|
|
|
|
</li>
|
2023-03-27 04:43:39 +02:00
|
|
|
{/if}
|