mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 07:33:07 +08:00
fix: avoid undefined when passing class-name as prop (#270)
- avoid `undefined` when passing class-name as prop - use built-in `class:list` directive
This commit is contained in:
@@ -7,13 +7,19 @@ export interface Props {
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
const { href, className, ariaLabel, title, disabled = false } = Astro.props;
|
||||
const {
|
||||
href,
|
||||
className = "",
|
||||
ariaLabel,
|
||||
title,
|
||||
disabled = false,
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
{
|
||||
disabled ? (
|
||||
<span
|
||||
class={`group inline-block ${className}`}
|
||||
class:list={["group inline-block", className]}
|
||||
aria-label={ariaLabel}
|
||||
title={title}
|
||||
aria-disabled={disabled}
|
||||
@@ -23,7 +29,7 @@ const { href, className, ariaLabel, title, disabled = false } = Astro.props;
|
||||
) : (
|
||||
<a
|
||||
{href}
|
||||
class={`group inline-block hover:text-skin-accent ${className}`}
|
||||
class:list={["group inline-block hover:text-skin-accent", className]}
|
||||
aria-label={ariaLabel}
|
||||
title={title}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user