feat(frontend): don't make link a link if it's not a link
This commit is contained in:
parent
ed60340969
commit
80ac218376
1 changed files with 9 additions and 2 deletions
|
@ -6,6 +6,9 @@
|
||||||
let displayLink: string;
|
let displayLink: string;
|
||||||
$: displayLink = prettifyLink(link);
|
$: displayLink = prettifyLink(link);
|
||||||
|
|
||||||
|
let isLink = true;
|
||||||
|
$: isLink = link.startsWith("http://") || link.startsWith("https://");
|
||||||
|
|
||||||
const prettifyLink = (raw: string) => {
|
const prettifyLink = (raw: string) => {
|
||||||
let out = raw;
|
let out = raw;
|
||||||
if (raw.startsWith("https://")) out = raw.substring("https://".length);
|
if (raw.startsWith("https://")) out = raw.substring("https://".length);
|
||||||
|
@ -17,5 +20,9 @@
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Icon name="globe" />
|
<Icon name="globe" aria-label="Link" />
|
||||||
<a href={link} rel="me nofollow noreferrer" target="_blank">{displayLink}</a>
|
{#if isLink}
|
||||||
|
<a href={link} rel="me nofollow noreferrer" target="_blank">{displayLink}</a>
|
||||||
|
{:else}
|
||||||
|
<span>{link}</span>
|
||||||
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue