CategoryDetail.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { type FC } from "react";
  2. import type { FunctionComponent } from "react";
  3. import clsx from "clsx";
  4. import Link from "next/link";
  5. interface TextProps {
  6. html: string;
  7. className?: string;
  8. }
  9. export const CategoryDetail: FC<{
  10. categoryItem: {
  11. description: string;
  12. name: string;
  13. };
  14. }> = ({ categoryItem }) => {
  15. if (!categoryItem) return null;
  16. return (
  17. <div className="px-4 w-full max-w-screen-2xl mt-8 md:mt-14 mx-auto mb-0 sm:mb-10">
  18. <div className="flex flex-col lg:flex-row justify-between gap-4 md:gap-8 lg:gap-20 items-start">
  19. <div className=" flex-col gap-3 shrink-0">
  20. <Link href="/" className="hidden lg:flex w-fit text-sm font-medium text-nowrap relative text-neutral-500 before:absolute before:bottom-0 before:left-0 before:h-px before:w-0 before:bg-current before:transition-all before:duration-300 before:content-[''] hover:text-black hover:before:w-full dark:text-neutral-400 dark:hover:text-neutral-300">
  21. Home /
  22. </Link>
  23. <h1 className="text-xl md:text-3xl font-bold tracking-tight text-black dark:text-white capitalize">
  24. {categoryItem.name}
  25. </h1>
  26. </div>
  27. <div className="w-full md:max-w-2xl lg:max-w-3xl">
  28. {categoryItem.description && (
  29. <Prose
  30. className="w-full text-base text-gray-600 dark:text-gray-300"
  31. html={categoryItem.description}
  32. />
  33. )}
  34. </div>
  35. </div>
  36. </div>
  37. );
  38. };
  39. const Prose: FunctionComponent<TextProps> = ({ html, className }) => {
  40. return (
  41. <div
  42. dangerouslySetInnerHTML={{ __html: html as string }}
  43. className={clsx(
  44. "prose prose-h1:text-[24px]",
  45. className
  46. )}
  47. />
  48. );
  49. };
  50. export default Prose;