feat(frontend): don't make link a link if it's not a link

This commit is contained in:
Sam 2023-03-27 04:43:39 +02:00
parent ed60340969
commit 80ac218376
Signed by: sam
GPG key ID: B4EF20DDE721CAA1

View file

@ -6,6 +6,9 @@
let displayLink: string;
$: displayLink = prettifyLink(link);
let isLink = true;
$: isLink = link.startsWith("http://") || link.startsWith("https://");
const prettifyLink = (raw: string) => {
let out = raw;
if (raw.startsWith("https://")) out = raw.substring("https://".length);
@ -17,5 +20,9 @@
};
</script>
<Icon name="globe" />
<a href={link} rel="me nofollow noreferrer" target="_blank">{displayLink}</a>
<Icon name="globe" aria-label="Link" />
{#if isLink}
<a href={link} rel="me nofollow noreferrer" target="_blank">{displayLink}</a>
{:else}
<span>{link}</span>
{/if}