index.tsx 695 B

1234567891011121314151617181920212223242526272829303132
  1. import clsx from "clsx";
  2. import Link from "next/link";
  3. import type { ElementType } from "react";
  4. interface NovelCoverProps {
  5. component?: ElementType;
  6. className?: string;
  7. href?: string;
  8. title?: string;
  9. alt?: string;
  10. src?: string;
  11. }
  12. export default function NovelCover(props: NovelCoverProps) {
  13. let { component: Component = Link } = props;
  14. const { className, alt = "", src = "", ...other } = props;
  15. if (!other.href) {
  16. Component = "div";
  17. }
  18. return (
  19. <Component className={clsx("novel-cover", className)} {...other}>
  20. <img
  21. src={src}
  22. alt={alt || other.title || ""}
  23. draggable="false"
  24. loading="lazy"
  25. />
  26. </Component>
  27. );
  28. }