import React, { ReactNode } from "react";
import styles from "./NewsCard.module.css";

interface NewsCardProps {
  date: Date;
  author: string;
  children: ReactNode;
}

export const NewsCard: React.FC<NewsCardProps> = ({
  date,
  author,
  children,
}) => {
  return (
    <article className={styles.card}>
      <h3>
        <time className={styles.date} dateTime={date.toISOString()}>
          {date.toLocaleDateString("en-US", {
            year: "numeric",
            month: "long",
            day: "numeric",
          })}
        </time>
      </h3>
      <address className={styles.author}>{author}</address>
      <div className={styles.content}>{children}</div>
    </article>
  );
};
