Skip to content

Commit 5717868

Browse files
committed
Give option to specify _self open link
1 parent 21b57a5 commit 5717868

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

src/components/Link.astro

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
---
2-
const { url } = Astro.props;
2+
interface Props {
3+
url: string;
4+
self?: boolean;
5+
}
6+
7+
const { url, self } = Astro.props;
8+
const target = self ? '_self' : '_blank';
39
---
410

511
<a
612
href={url}
7-
target='_blank'
8-
rel='noopener noreferrer'
13+
target={target}
14+
rel={target === '_blank' ? 'noopener noreferrer' : undefined}
915
class='not-prose font-normal text-blue-800 hover:text-blue-700 dark:text-blue-300 dark:hover:text-blue-200'
10-
><slot /></a
1116
>
17+
<slot />
18+
</a>

0 commit comments

Comments
 (0)