mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +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,
|
pubDatetime,
|
||||||
modDatetime,
|
modDatetime,
|
||||||
size = "sm",
|
size = "sm",
|
||||||
className,
|
className = "",
|
||||||
}: Props) {
|
}: Props) {
|
||||||
return (
|
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
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
className={`${
|
className={`${
|
||||||
|
|||||||
@@ -7,13 +7,19 @@ export interface Props {
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { href, className, ariaLabel, title, disabled = false } = Astro.props;
|
const {
|
||||||
|
href,
|
||||||
|
className = "",
|
||||||
|
ariaLabel,
|
||||||
|
title,
|
||||||
|
disabled = false,
|
||||||
|
} = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
{
|
{
|
||||||
disabled ? (
|
disabled ? (
|
||||||
<span
|
<span
|
||||||
class={`group inline-block ${className}`}
|
class:list={["group inline-block", className]}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
title={title}
|
title={title}
|
||||||
aria-disabled={disabled}
|
aria-disabled={disabled}
|
||||||
@@ -23,7 +29,7 @@ const { href, className, ariaLabel, title, disabled = false } = Astro.props;
|
|||||||
) : (
|
) : (
|
||||||
<a
|
<a
|
||||||
{href}
|
{href}
|
||||||
class={`group inline-block hover:text-skin-accent ${className}`}
|
class:list={["group inline-block hover:text-skin-accent", className]}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
title={title}
|
title={title}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user