refactor: migrate Preact components to Astro

This commit is contained in:
Stefan Imhoff
2024-09-09 18:42:43 +02:00
parent d77c513b7b
commit 526fe22cda
130 changed files with 1154 additions and 1274 deletions

25
src/components/Link.astro Normal file
View 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>