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:
@@ -14,10 +14,12 @@ export default function Datetime({
|
||||
pubDatetime,
|
||||
modDatetime,
|
||||
size = "sm",
|
||||
className,
|
||||
className = "",
|
||||
}: Props) {
|
||||
return (
|
||||
<div className={`flex items-center space-x-2 opacity-80 ${className}`}>
|
||||
<div
|
||||
className={`flex items-center space-x-2 opacity-80 ${className}`.trim()}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
className={`${
|
||||
|
||||
@@ -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