Dev Helpers
← Back

Featured story and secondary links

Place this file at components/FeaturedStoryAndSecondaryLinks.tsx in an App Router project.

Open this example in the interactive library

Source code

// components/FeaturedStoryAndSecondaryLinks.tsx

import Link from "next/link";

export default function FeaturedStoryAndSecondaryLinks({
  items = [
    { slug: "getting-started", title: "Getting started" },
    { slug: "building", title: "Building" },
  ],
}: { items?: { slug: string; title: string }[] } = {}) {
  const [lead, ...others] = items;
  return lead ? (
    <section>
      <h2>
        <Link href={"/news/" + encodeURIComponent(lead.slug)}>{lead.title}</Link>
      </h2>
      {others.map((i) => (
        <p key={i.slug}>
          <Link href={"/news/" + encodeURIComponent(i.slug)}>{i.title}</Link>
        </p>
      ))}
    </section>
  ) : (
    <p>No stories published.</p>
  );
}