Dev Helpers
← Back

Newest publication shelf

Place this file at app/books/page.tsx in an App Router project.

Open this example in the interactive library

Source code

// app/books/page.tsx

export default function NewestPublicationShelf() {
  const books = [
    { slug: "ink", name: "Print in Ink", year: 2020, genre: "Art", loans: 14 },
    { slug: "type", name: "Type Design", year: 2024, genre: "Design", loans: 8 },
    { slug: "paper", name: "Paper Works", year: 2024, genre: "Art", loans: 22 },
  ];
  const newest = Math.max(...books.map((b) => b.year));
  return (
    <main>
      <h1>New in {newest}</h1>
      {books
        .filter((b) => b.year === newest)
        .map((b) => (
          <p key={b.slug}>{b.name}</p>
        ))}
    </main>
  );
}