diff --git a/components/BlogCard.js b/components/BlogCard.js deleted file mode 100644 index 216f0c4..0000000 --- a/components/BlogCard.js +++ /dev/null @@ -1,33 +0,0 @@ -import Link from "next/link"; -import BlurImage from "./BlurImage"; -import Date from "./Date"; - -export default function BlogCard({ data }) { - return ( - - -
- -
-

{data.title}

-

- {data.description} -

-

- Published -

-
-
-
- - ); -} diff --git a/components/BlogCard.tsx b/components/BlogCard.tsx new file mode 100644 index 0000000..e0a4704 --- /dev/null +++ b/components/BlogCard.tsx @@ -0,0 +1,48 @@ +import Link from "next/link"; +import BlurImage from "./BlurImage"; +import Date from "./Date"; + +import type { Post } from "@prisma/client"; + +interface BlogCardProps { + data: Pick< + Post, + "slug" | "image" | "imageBlurhash" | "title" | "description" | "createdAt" + >; +} + +export default function BlogCard({ data }: BlogCardProps) { + return ( + + +
+ {data.image ? ( + + ) : ( +
+ ? +
+ )} +
+

{data.title}

+

+ {data.description} +

+

+ Published +

+
+
+
+ + ); +} diff --git a/components/BlurImage.js b/components/BlurImage.tsx similarity index 65% rename from components/BlurImage.js rename to components/BlurImage.tsx index a6e9cd2..8f606ab 100644 --- a/components/BlurImage.js +++ b/components/BlurImage.tsx @@ -1,8 +1,15 @@ +import cn from "clsx"; import Image from "next/image"; import { useState } from "react"; -import cn from "clsx"; -export default function BlurImage(props) { +import type { ComponentProps } from "react"; +import type { WithClassName } from "@/types"; + +interface BlurImageProps extends WithClassName, ComponentProps { + alt: string; +} + +export default function BlurImage(props: BlurImageProps) { const [isLoading, setLoading] = useState(true); return ( diff --git a/components/Cloudinary.js b/components/Cloudinary.js deleted file mode 100644 index 84019d5..0000000 --- a/components/Cloudinary.js +++ /dev/null @@ -1,48 +0,0 @@ -import { Component } from "react"; -import Head from "next/head"; - -export default class CloudinaryUploadWidget extends Component { - constructor(props) { - super(props); - this.uploader = null; - } - - showWidget = () => { - const { callback } = this.props; - let widget = window.cloudinary.createUploadWidget( - { - cloudName: "vercel-platforms", - uploadPreset: "w0vnflc6", - cropping: true, - }, - (error, result) => { - if (!error && result && result.event === "success") { - callback(result.info); - } - } - ); - widget.open(); - }; - - open = (e) => { - e.preventDefault(); - this.showWidget(); - }; - - render() { - return ( - <> - - // this is Next.js specific, but if you're using something like Create - React App, // you could download the script in componentDidMount using - this method: https://stackoverflow.com/a/34425083/1424568 -