mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
refactor: migrate Preact components to Astro
This commit is contained in:
25
src/components/Link.astro
Normal file
25
src/components/Link.astro
Normal file
@@ -0,0 +1,25 @@
|
||||
---
|
||||
// Cspell:words astro classnames noopener noreferrer
|
||||
import cx from 'classnames';
|
||||
|
||||
interface Props {
|
||||
class?: string;
|
||||
href?: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
const { class: className, href = '#', ...props } = Astro.props;
|
||||
|
||||
const isExternal = (href as string).startsWith('http');
|
||||
const classes = cx('link', { external: isExternal }, className);
|
||||
---
|
||||
|
||||
<a
|
||||
class={classes}
|
||||
href={href}
|
||||
rel={isExternal ? 'nofollow noopener noreferrer' : undefined}
|
||||
target={isExternal ? '_blank' : undefined}
|
||||
{...props}
|
||||
>
|
||||
<slot />
|
||||
</a>
|
||||
Reference in New Issue
Block a user