File size: 502 Bytes
43a06dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script lang="ts">
    export let href: string;

    // rel is passed by MDsveX, but we don't need it, so we just ignore it
    // no way to change this behavior atm (https://github.com/pngwn/MDsveX/issues/609)
    export let rel: string = "";
    rel;

    const [ target, _rel ] = (() => {
        try {
            new URL(href)
            return [ '_blank', 'noopener noreferrer' ];
        } catch {}

        return [];
    })();
</script>

<a rel={_rel} {target} {href}>
    <slot></slot>
</a>