index.tsx 697 B

12345678910111213141516171819202122232425262728293031323334353637
  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 {
  14. component: Component = Link,
  15. className,
  16. alt = "",
  17. src = "",
  18. ...other
  19. } = props;
  20. if (!other.href) {
  21. Component = "div";
  22. }
  23. return (
  24. <Component className={clsx("novel-cover", className)} {...other}>
  25. <img
  26. src={src}
  27. alt={alt || other.title || ""}
  28. draggable="false"
  29. loading="lazy"
  30. />
  31. </Component>
  32. );
  33. }