import clsx from "clsx"; import copy from "copy-to-clipboard"; import React, { useState } from "react"; import Link from "@docusaurus/Link"; import type { IconName } from "@fortawesome/fontawesome-common-types"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import type { Obj } from "../../libs/store"; import Tag from "../Tag"; export default function Card({ module_name, name, desc, author, homepage, tags, is_official, action, actionDisabled = false, actionLabel = "点击复制安装命令", }: Obj & { action?: string; actionLabel?: string; actionDisabled?: boolean; }): JSX.Element { const isGithub = /^https:\/\/github.com\/[^/]+\/[^/]+/.test(homepage); const [copied, setCopied] = useState(false); const copyAction = () => { copy(action); setCopied(true); setTimeout(() => setCopied(false), 2000); }; return (
{name} {is_official && ( )} {homepage && ( {isGithub ? ( ) : ( )} )}
{tags && (
{tags.map((tag, index) => ( ))}
)} {desc && (
{desc}
)} {module_name && (
{module_name}
)} {author && (
{author}
)} {action && actionLabel && ( )}
); }