import { formatDate } from '@/lib/helpers'
import Link from 'next/link'

export default function StaticContentList ({ entries, urlPrefix, max = 0 }) {
  return (
    <table>
      <tbody>
        {entries.map((e) => (
          <tr key={e.slug}>
            <td>{!!e.datePublished && <span>{formatDate(e.datePublished)}</span>}</td>
            <td>
              <Link href={`${urlPrefix}${e.slug}`}>{e.title}</Link>
            </td>
          </tr>
        )).slice(0, max > 0 ? max : entries.length)}
      </tbody>
    </table>
  )
}
