# Add the "Error 404" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/error-404) to this Pantheon Content Publisher (P1) Next.js project. A friendly page-not-found message with a search box and popular links, so a dead end becomes a next step.

## Steps

1. Create `components/puck/error-404-block.tsx` with the exact file contents below. If `components/puck/` doesn't exist, find the folder where this project keeps its Puck components (look at the imports in `puck.config.tsx`) and put it there.
2. In `puck.config.tsx`, import it: `import { error404Block } from "./components/puck/error-404-block";`
3. Register it under `components` as `Error404Block: error404Block`.
4. Add `"Error404Block"` to the best-fitting entry in `categories` (this block's library category is "Civic & utility"). Create a category only if none fits.
5. Run the project's type check (usually `pnpm typecheck`) and resolve anything project-specific.
6. If `package.json` has a `sync:registry` script, tell the user it must run (or that CI will run it) before the new component appears in the P1 editor.

## Rules

- Do not add dependencies. The block is self-contained by design: one type-only import from `@puckeditor/core`, Tailwind v4 classes, no client JavaScript.
- Keep the files as-is unless the user asks for changes. The accent color is `indigo-*`; if the project has brand colors, offer to swap them with a find-and-replace on `indigo-`.
- Images are plain `imageUrl` + `imageAlt` text fields. If this project defines a P1 media-library field (search for `"p1-media"`), offer to switch to it.
- Don't change prop names in `defaultProps`. Content editors' saved pages depend on them.

## File: `components/puck/error-404-block.tsx`

```tsx
import type { ComponentConfig } from "@puckeditor/core";

/**
 * Error 404 — a friendly "page not found" with a search box and helpful links, so a dead end
 * becomes a next step. Use it on your not-found page.
 * Register: `Error404Block: error404Block` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";

export type Error404Props = {
  code: string;
  heading: string;
  headingLevel: Heading;
  message: string;
  formAction: string;
  queryParam: string;
  searchLabel: string;
  buttonLabel: string;
  linksHeading: string;
  links: { label: string; description: string; href: string }[];
  homeLabel: string;
  homeHref: string;
  contactText: string;
  contactLabel: string;
  contactHref: string;
};

const childLevel = { h1: "h2", h2: "h3", h3: "h4", h4: "h5" } as const;
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";

export const error404Block: ComponentConfig<Error404Props> = {
  label: "Error 404",
  fields: {
    code: { type: "text", label: "Error code", metadata: { help: "Shown large, like 404. Screen readers hear \"Error 404\". Leave blank to hide it." } },
    heading: { type: "text", label: "Heading" },
    headingLevel: {
      type: "select",
      label: "Heading level",
      options: [
        { label: "H1", value: "h1" },
        { label: "H2", value: "h2" },
        { label: "H3", value: "h3" },
        { label: "H4", value: "h4" },
      ],
      metadata: { help: "Sets the page outline for screen readers and search. The look doesn't change. On a not-found page this is usually H1." },
    },
    message: { type: "textarea", label: "Message" },
    formAction: { type: "text", label: "Search page URL", metadata: { help: "Where the search box sends people, like /search. Leave blank to hide the search box." } },
    queryParam: { type: "text", label: "Search parameter name", metadata: { help: "The URL name for the search terms, usually q." } },
    searchLabel: { type: "text", label: "Search box label" },
    buttonLabel: { type: "text", label: "Search button text" },
    linksHeading: { type: "text", label: "Links heading" },
    links: {
      type: "array",
      label: "Helpful links",
      min: 0,
      max: 8,
      getItemSummary: (item) => item?.label || "Link",
      defaultItemProps: { label: "New link", description: "", href: "/" },
      arrayFields: {
        label: { type: "text", label: "Label" },
        description: { type: "text", label: "Description", metadata: { help: "One short line. Leave blank to hide it." } },
        href: { type: "text", label: "Link" },
      },
    },
    homeLabel: { type: "text", label: "Home link text", metadata: { help: "Leave blank to hide it." } },
    homeHref: { type: "text", label: "Home link" },
    contactText: { type: "text", label: "Contact sentence", metadata: { help: "Shown before the contact link, like Think something is broken?" } },
    contactLabel: { type: "text", label: "Contact link text", metadata: { help: "Leave blank to hide the contact line." } },
    contactHref: { type: "text", label: "Contact link", metadata: { help: "A path, URL or mailto: address." } },
  },
  defaultProps: {
    code: "404",
    heading: "We can't find that page",
    headingLevel: "h1",
    message: "It may have moved when we updated our site, or the link may have a typo. Try a search, or pick up from one of the pages people visit most.",
    formAction: "/search",
    queryParam: "q",
    searchLabel: "Search the site",
    buttonLabel: "Search",
    linksHeading: "Popular pages",
    links: [
      { label: "Programs & classes", description: "Camps, sports, fitness and art for every age.", href: "/programs" },
      { label: "Find a park", description: "Maps, amenities and trail conditions.", href: "/parks" },
      { label: "Reserve a shelter", description: "Book picnic shelters and fields online.", href: "/parks/shelters" },
      { label: "Events calendar", description: "Concerts, cleanups and family nights.", href: "/events" },
    ],
    homeLabel: "Back to home",
    homeHref: "/",
    contactText: "Think a link is broken?",
    contactLabel: "Let us know",
    contactHref: "mailto:web@riverbendparks.org?subject=Broken%20link",
  },
  render: ({ id, code, heading, headingLevel, message, formAction, queryParam, searchLabel, buttonLabel, linksHeading, links, homeLabel, homeHref, contactText, contactLabel, contactHref }) => {
    const H = headingLevel || "h1";
    const Sub = childLevel[H] ?? "h2";
    const list = (links ?? []).filter((l) => l?.label);
    const inputId = `notfound-search-${id}`;

    return (
      <section className="relative isolate overflow-hidden bg-white px-4 py-16 sm:px-6 sm:py-24 lg:px-8 lg:py-32">
        <svg aria-hidden="true" className="absolute inset-0 -z-10 size-full stroke-neutral-200 mask-radial-at-top-left mask-radial-from-10% mask-radial-to-70%">
          <defs>
            <pattern id={`grid-${id}`} width="48" height="48" patternUnits="userSpaceOnUse">
              <path d="M48 0H0v48" fill="none" />
            </pattern>
          </defs>
          <rect width="100%" height="100%" fill={`url(#grid-${id})`} strokeWidth="0" />
        </svg>
        <div className="mx-auto grid max-w-6xl grid-cols-1 gap-12 lg:grid-cols-12 lg:gap-16">
          <div className="lg:col-span-7">
            {code ? (
              <p className="text-7xl leading-none font-semibold tracking-tighter text-indigo-600 tabular-nums sm:text-8xl lg:text-9xl">
                <span className="sr-only">Error </span>
                {code}
              </p>
            ) : null}
            {heading ? (
              <H className={`text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-5xl ${code ? "mt-6" : ""}`}>{heading}</H>
            ) : null}
            {message ? <p className="mt-5 max-w-xl text-base leading-7 text-pretty text-neutral-600 sm:text-lg sm:leading-8">{message}</p> : null}
            {formAction ? (
              <form role="search" action={formAction} method="get" className="mt-8 flex max-w-xl flex-col gap-3 sm:flex-row">
                <label htmlFor={inputId} className="sr-only">
                  {searchLabel || "Search the site"}
                </label>
                <div className="relative min-w-0 flex-1">
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="pointer-events-none absolute top-1/2 left-4 size-5 -translate-y-1/2 text-neutral-500">
                    <path fillRule="evenodd" d="M9 3.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11ZM2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Z" clipRule="evenodd" />
                  </svg>
                  <input
                    id={inputId}
                    type="search"
                    name={queryParam || "q"}
                    placeholder={searchLabel || "Search the site"}
                    className="block min-h-12 w-full rounded-lg border-0 bg-white py-3 pr-4 pl-11 text-base text-neutral-950 shadow-sm ring-1 ring-neutral-300 ring-inset placeholder:text-neutral-500 focus:ring-2 focus:ring-indigo-600 focus:outline-none"
                  />
                </div>
                <button
                  type="submit"
                  className={`inline-flex min-h-12 shrink-0 items-center justify-center rounded-lg bg-indigo-600 px-6 py-3 text-base font-semibold text-white shadow-sm transition hover:bg-indigo-700 ${focusRing}`}
                >
                  {buttonLabel || "Search"}
                </button>
              </form>
            ) : null}
            {homeLabel || contactLabel ? (
              <div className="mt-8 flex flex-wrap items-center gap-x-6 gap-y-2 text-sm">
                {homeLabel ? (
                  <a href={homeHref || "/"} className={`group inline-flex min-h-11 items-center gap-1.5 rounded font-semibold text-indigo-700 hover:text-indigo-900 ${focusRing}`}>
                    <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 transition group-hover:-translate-x-0.5">
                      <path fillRule="evenodd" d="M17 10a.75.75 0 0 1-.75.75H5.612l3.22 3.22a.75.75 0 1 1-1.06 1.06l-4.5-4.5a.75.75 0 0 1 0-1.06l4.5-4.5a.75.75 0 0 1 1.06 1.06l-3.22 3.22h10.638A.75.75 0 0 1 17 10Z" clipRule="evenodd" />
                    </svg>
                    {homeLabel}
                  </a>
                ) : null}
                {contactLabel ? (
                  <p className="text-neutral-600">
                    {contactText ? `${contactText} ` : ""}
                    <a
                      href={contactHref || "#"}
                      className={`inline-flex min-h-11 items-center rounded font-semibold text-neutral-950 underline decoration-neutral-300 underline-offset-4 hover:decoration-indigo-600 ${focusRing}`}
                    >
                      {contactLabel}
                    </a>
                  </p>
                ) : null}
              </div>
            ) : null}
          </div>

          {list.length ? (
            <div className="lg:col-span-5 lg:pt-4">
              {linksHeading ? <Sub className="text-sm font-semibold tracking-widest text-neutral-950 uppercase">{linksHeading}</Sub> : null}
              <ul role="list" className={`divide-y divide-neutral-200 border-y border-neutral-200 ${linksHeading ? "mt-4" : ""}`}>
                {list.map((l, i) => (
                  <li key={`${l.label}-${i}`}>
                    <a href={l.href || "#"} className={`group flex min-h-11 items-center gap-4 rounded-lg py-4 ${focusRing}`}>
                      <span className="min-w-0 flex-1">
                        <span className="block text-base font-semibold text-neutral-950 group-hover:text-indigo-700">{l.label}</span>
                        {l.description ? <span className="mt-0.5 block text-sm leading-6 text-neutral-600">{l.description}</span> : null}
                      </span>
                      <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 shrink-0 text-neutral-400 transition group-hover:translate-x-0.5 group-hover:text-indigo-600">
                        <path fillRule="evenodd" d="M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z" clipRule="evenodd" />
                      </svg>
                    </a>
                  </li>
                ))}
              </ul>
            </div>
          ) : null}
        </div>
      </section>
    );
  },
};
```
