# Add the "Trail Guide" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/trail-guide) to this Pantheon Content Publisher (P1) Next.js project. Trails as cards or rows with distance, difficulty by shape and word, surface, elevation, accessibility, dogs, trailhead and GPX.

## Steps

1. Create `components/puck/trail-guide-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 { trailGuideBlock } from "./components/puck/trail-guide-block";`
3. Register it under `components` as `TrailGuideBlock: trailGuideBlock`.
4. Add `"TrailGuideBlock"` to the best-fitting entry in `categories` (this block's library category is "Parks & rec"). 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/trail-guide-block.tsx`

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

/**
 * Trail Guide — trails as photo cards or compact rows with distance, difficulty (shape plus
 * word, never color alone), surface, elevation, route type, accessibility, dogs and trailhead,
 * plus map and GPX links and a difficulty legend.
 * Register: `TrailGuideBlock: trailGuideBlock` in puck.config.tsx.
 */

type Heading = "h1" | "h2" | "h3" | "h4";
type Difficulty = "easy" | "moderate" | "hard";
type Route = "loop" | "out-and-back" | "point-to-point";
type Dogs = "leashed" | "none" | "off-leash";

export type TrailGuideProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  layout: "cards" | "rows";
  showLegend: boolean;
  easyNote: string;
  moderateNote: string;
  hardNote: string;
  trails: {
    name: string;
    park: string;
    imageUrl: string;
    imageAlt: string;
    distance: string;
    difficulty: Difficulty;
    surface: string;
    elevation: string;
    route: Route;
    accessibility: string;
    dogs: Dogs;
    trailhead: string;
    mapHref: string;
    gpxHref: string;
  }[];
  footnote: string;
  allTrailsLabel: string;
  allTrailsHref: string;
};

const childHeading = { 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-700";

// Trail-sign convention: circle, square, diamond. The shape and the word carry the meaning.
const difficulties: Record<Difficulty, { label: string; shape: "circle" | "square" | "diamond" }> = {
  easy: { label: "Easy", shape: "circle" },
  moderate: { label: "Moderate", shape: "square" },
  hard: { label: "Hard", shape: "diamond" },
};

const routes: Record<Route, string> = {
  loop: "Loop",
  "out-and-back": "Out and back",
  "point-to-point": "Point to point",
};

const dogRules: Record<Dogs, string> = {
  leashed: "Dogs on leash",
  none: "No dogs",
  "off-leash": "Off-leash area",
};

function DifficultyIcon({ level, className }: { level: Difficulty; className: string }) {
  const shape = difficulties[level]?.shape ?? "circle";
  return (
    <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className={className}>
      {shape === "circle" ? <circle cx="10" cy="10" r="6.5" /> : null}
      {shape === "square" ? <rect x="4" y="4" width="12" height="12" rx="1" /> : null}
      {shape === "diamond" ? <path d="M10 1.75 18.25 10 10 18.25 1.75 10Z" /> : null}
    </svg>
  );
}

const icons = {
  distance: "M3 17 8 4l4 9 2-4 3 8M3 17h18",
  elevation: "M3 20h18L14.5 8 11 13.5 8.5 10 3 20Zm11.5-12V4l3 1.5-3 1.5",
  route: "M6 19a2 2 0 1 0 0-4 2 2 0 0 0 0 4Zm12-10a2 2 0 1 0 0-4 2 2 0 0 0 0 4ZM6 15V9a4 4 0 0 1 4-4h6M18 9v6a4 4 0 0 1-4 4H8",
  surface: "M4 20 9 4m6 0 5 16M12 6v2m0 4v2m0 4v2",
  dog: "M10 5.5 8 3H5L3 6v3l2 1v4l-1 7h3l1-5h6l1 5h3l-1-7V9l2-2-2-2h-3l-2 2h-3ZM6 6.5h.01",
  accessible: "M12 5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3ZM9 8h6m-3 0v6h4l2 5M9.5 11.5a5 5 0 1 0 6 7",
  parking: "M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2Zm4 14V7h4a3 3 0 0 1 0 6H9",
} as const;

function LineIcon({ d, className = "size-4 shrink-0 text-neutral-500" }: { d: string; className?: string }) {
  return (
    <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={1.75} strokeLinecap="round" strokeLinejoin="round" className={className}>
      <path d={d} />
    </svg>
  );
}

export const trailGuideBlock: ComponentConfig<TrailGuideProps> = {
  label: "Trail Guide",
  fields: {
    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." },
    },
    intro: { type: "textarea", label: "Intro", metadata: { help: "Leave blank to hide it." } },
    layout: {
      type: "radio",
      label: "Layout",
      options: [
        { label: "Cards", value: "cards" },
        { label: "Rows", value: "rows" },
      ],
      metadata: { help: "Cards show photos in a grid. Rows fit more trails on the page and hide photos." },
    },
    showLegend: {
      type: "radio",
      label: "Difficulty legend",
      options: [
        { label: "Show", value: true },
        { label: "Hide", value: false },
      ],
    },
    easyNote: { type: "text", label: "Easy means…", metadata: { help: "One short line for the legend." } },
    moderateNote: { type: "text", label: "Moderate means…" },
    hardNote: { type: "text", label: "Hard means…" },
    trails: {
      type: "array",
      label: "Trails",
      min: 1,
      max: 24,
      getItemSummary: (item) => (item?.name ? `${difficulties[item.difficulty]?.label ?? "Easy"} · ${item.name}` : "Trail"),
      defaultItemProps: {
        name: "New trail",
        park: "",
        imageUrl: "",
        imageAlt: "",
        distance: "",
        difficulty: "easy",
        surface: "",
        elevation: "",
        route: "loop",
        accessibility: "",
        dogs: "leashed",
        trailhead: "",
        mapHref: "",
        gpxHref: "",
      },
      arrayFields: {
        name: { type: "text", label: "Trail name" },
        park: { type: "text", label: "Park", metadata: { help: "Which park the trail is in. Leave blank to hide it." } },
        imageUrl: { type: "text", label: "Image URL", metadata: { help: "Shown in the Cards layout only. Leave blank for a text card." } },
        imageAlt: { type: "text", label: "Image description", metadata: { help: "Describe what the photo shows for people who can't see it." } },
        distance: { type: "text", label: "Distance", metadata: { help: "Write it the way hikers read it, like 2.4 mi (3.9 km)." } },
        difficulty: {
          type: "select",
          label: "Difficulty",
          options: [
            { label: "Easy", value: "easy" },
            { label: "Moderate", value: "moderate" },
            { label: "Hard", value: "hard" },
          ],
          metadata: { help: "Shown as a shape and a word, so it doesn't rely on color." },
        },
        surface: { type: "text", label: "Surface", metadata: { help: "Like Paved, Crushed limestone, or Natural dirt with roots." } },
        elevation: { type: "text", label: "Elevation gain", metadata: { help: "Like 120 ft (37 m). Leave blank for flat trails." } },
        route: {
          type: "select",
          label: "Route type",
          options: [
            { label: "Loop", value: "loop" },
            { label: "Out and back", value: "out-and-back" },
            { label: "Point to point", value: "point-to-point" },
          ],
        },
        accessibility: {
          type: "textarea",
          label: "Accessibility notes",
          metadata: { help: "Be specific: which part is accessible, grades, benches, accessible parking. Leave blank to hide it." },
        },
        dogs: {
          type: "select",
          label: "Dogs",
          options: [
            { label: "Dogs on leash", value: "leashed" },
            { label: "No dogs", value: "none" },
            { label: "Off-leash area", value: "off-leash" },
          ],
        },
        trailhead: { type: "text", label: "Trailhead & parking", metadata: { help: "Where to start and park, like Lot B off Mill Road, 40 spaces." } },
        mapHref: { type: "text", label: "Map link", metadata: { help: "A trail map or directions link. Leave blank to hide it." } },
        gpxHref: { type: "text", label: "GPX file link", metadata: { help: "For GPS apps. Leave blank to hide it." } },
      },
    },
    footnote: { type: "textarea", label: "Footnote", metadata: { help: "Like trail etiquette or how distances were measured. Leave blank to hide it." } },
    allTrailsLabel: { type: "text", label: "All trails link text", metadata: { help: "Leave blank to hide the link." } },
    allTrailsHref: { type: "text", label: "All trails link" },
  },
  defaultProps: {
    heading: "Trails worth the drive",
    headingLevel: "h2",
    intro: "Cedar Valley Park District maintains 31 miles of trails across 12 parks. Distances are one way unless the trail is a loop.",
    layout: "cards",
    showLegend: true,
    easyNote: "Mostly flat, wide and firm. Good for strollers and new walkers.",
    moderateNote: "Some hills, roots or loose gravel. Sturdy shoes help.",
    hardNote: "Steep climbs, rocky or narrow sections. Plan for extra time.",
    trails: [
      {
        name: "Millrace Greenway",
        park: "Cedar Valley Riverfront",
        imageUrl: "https://picsum.photos/seed/greenway/800/533",
        imageAlt: "A paved path curving along a slow river under tall trees",
        distance: "3.1 mi (5 km)",
        difficulty: "easy",
        surface: "Paved",
        elevation: "40 ft (12 m)",
        route: "out-and-back",
        accessibility: "Fully paved and ADA-accessible end to end, with benches every quarter mile and accessible restrooms at the trailhead.",
        dogs: "leashed",
        trailhead: "Riverfront Lot A, 1200 Water Street. 60 spaces, 4 accessible.",
        mapHref: "/trails/millrace-greenway/map",
        gpxHref: "/trails/millrace-greenway.gpx",
      },
      {
        name: "Heron Marsh Loop",
        park: "Willow Bend Nature Preserve",
        imageUrl: "https://picsum.photos/seed/marsh/800/533",
        imageAlt: "A wooden boardwalk crossing tall marsh grasses",
        distance: "1.9 mi (3.1 km)",
        difficulty: "moderate",
        surface: "Crushed limestone and boardwalk",
        elevation: "110 ft (34 m)",
        route: "loop",
        accessibility: "ADA-accessible first 0.8 mi to the observation deck. Past the deck the trail narrows with grades up to 10%.",
        dogs: "none",
        trailhead: "Nature Center lot, 455 Willow Bend Road. Closes at dusk.",
        mapHref: "/trails/heron-marsh/map",
        gpxHref: "/trails/heron-marsh.gpx",
      },
      {
        name: "Ridgeback Trail",
        park: "Knob Hill Park",
        imageUrl: "https://picsum.photos/seed/ridge/800/533",
        imageAlt: "A rocky dirt trail climbing through a hardwood forest",
        distance: "4.6 mi (7.4 km)",
        difficulty: "hard",
        surface: "Natural dirt, rocks and roots",
        elevation: "780 ft (238 m)",
        route: "loop",
        accessibility: "Not accessible. Steep, uneven sections and stone steps. The Overlook Path from the same lot is paved for 0.3 mi.",
        dogs: "leashed",
        trailhead: "Knob Hill upper lot, 9800 Ridge Road. Fills by 9 a.m. on weekends.",
        mapHref: "/trails/ridgeback/map",
        gpxHref: "/trails/ridgeback.gpx",
      },
    ],
    footnote: "Distances and elevation measured by Cedar Valley Park District staff with GPS. Trails close during lightning and may close after heavy rain.",
    allTrailsLabel: "See all 22 trails",
    allTrailsHref: "/trails",
  },
  render: ({
    id,
    heading,
    headingLevel,
    intro,
    layout,
    showLegend,
    easyNote,
    moderateNote,
    hardNote,
    trails,
    footnote,
    allTrailsLabel,
    allTrailsHref,
  }) => {
    const H = headingLevel || "h2";
    const Sub = childHeading[headingLevel] || "h3";
    const baseId = id || "trail-guide";
    const rows = layout === "rows";
    const list = (trails ?? []).filter((t) => t?.name);
    const legend = (
      [
        ["easy", easyNote],
        ["moderate", moderateNote],
        ["hard", hardNote],
      ] as [Difficulty, string][]
    ).map(([level, note]) => ({ level, note }));
    const hasHeader = Boolean(heading || intro || allTrailsLabel);

    return (
      <section aria-labelledby={heading ? `${baseId}-heading` : undefined} className="bg-white px-4 py-16 sm:px-6 sm:py-20 lg:px-8 lg:py-24">
        <div className="mx-auto max-w-7xl">
          {hasHeader ? (
            <div className="flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between sm:gap-10">
              <div className="max-w-2xl">
                {heading ? (
                  <H id={`${baseId}-heading`} className="text-3xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-4xl">
                    {heading}
                  </H>
                ) : null}
                {intro ? <p className="mt-4 text-lg leading-8 text-pretty text-neutral-600">{intro}</p> : null}
              </div>
              {allTrailsLabel ? (
                <a
                  href={allTrailsHref || "#"}
                  className={`group inline-flex min-h-11 shrink-0 items-center gap-1.5 self-start rounded text-base font-semibold text-indigo-700 hover:text-indigo-900 sm:self-auto ${focusRing}`}
                >
                  {allTrailsLabel}
                  <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 transition motion-safe:group-hover:translate-x-0.5">
                    <path fillRule="evenodd" d="M3 10a.75.75 0 0 1 .75-.75h10.64l-3.22-3.22a.75.75 0 1 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 1 1-1.06-1.06l3.22-3.22H3.75A.75.75 0 0 1 3 10Z" clipRule="evenodd" />
                  </svg>
                </a>
              ) : null}
            </div>
          ) : null}

          {showLegend !== false ? (
            <div className={`rounded-2xl bg-neutral-50 px-5 py-4 ring-1 ring-neutral-200 ring-inset sm:px-6 ${hasHeader ? "mt-8" : ""}`}>
              <p id={`${baseId}-legend`} className="text-xs font-semibold tracking-wider text-neutral-600 uppercase">
                Difficulty
              </p>
              <dl aria-labelledby={`${baseId}-legend`} className="mt-3 grid grid-cols-1 gap-x-8 gap-y-3 md:grid-cols-3">
                {legend.map(({ level, note }) => (
                  <div key={level} className="flex gap-3">
                    <dt className="flex w-28 shrink-0 items-center gap-2 self-start text-sm font-semibold text-neutral-950 md:w-auto">
                      <DifficultyIcon level={level} className="size-4 shrink-0 text-indigo-800" />
                      {difficulties[level].label}
                    </dt>
                    {note ? <dd className="min-w-0 text-sm leading-6 text-neutral-600 md:-mt-0.5">{note}</dd> : null}
                  </div>
                ))}
              </dl>
            </div>
          ) : null}

          {list.length ? (
            <ul
              role="list"
              className={`${rows ? "grid grid-cols-1 divide-y divide-neutral-200 border-y border-neutral-200" : "grid grid-cols-1 gap-x-6 gap-y-12 sm:grid-cols-2 lg:grid-cols-3"} ${hasHeader || showLegend !== false ? "mt-10 sm:mt-12" : ""}`}
            >
              {list.map((trail, i) => {
                const level: Difficulty = difficulties[trail.difficulty] ? trail.difficulty : "easy";
                type Fact = { term: string; value: string; icon: string } | null;
                const facts = ([
                  trail.distance ? { term: "Distance", value: trail.distance, icon: icons.distance } : null,
                  trail.elevation ? { term: "Elevation gain", value: trail.elevation, icon: icons.elevation } : null,
                  routes[trail.route] ? { term: "Route", value: routes[trail.route], icon: icons.route } : null,
                  trail.surface ? { term: "Surface", value: trail.surface, icon: icons.surface } : null,
                  dogRules[trail.dogs] ? { term: "Dogs", value: dogRules[trail.dogs], icon: icons.dog } : null,
                ] as Fact[]).filter((f): f is NonNullable<Fact> => Boolean(f));
                const showImage = !rows && Boolean(trail.imageUrl);
                return (
                  <li key={`${trail.name}-${i}`} className={rows ? "py-8 first:pt-8 sm:py-10" : "flex flex-col"}>
                    <article className={rows ? "grid grid-cols-1 gap-6 lg:grid-cols-12 lg:gap-10" : "flex h-full flex-col"}>
                      {showImage ? (
                        <img src={trail.imageUrl} alt={trail.imageAlt || ""} loading="lazy" className="aspect-3/2 w-full rounded-2xl bg-neutral-100 object-cover ring-1 ring-neutral-950/5" />
                      ) : null}

                      <div className={rows ? "lg:col-span-4" : showImage ? "mt-5" : "border-t-2 border-indigo-700 pt-5"}>
                        <p className="inline-flex items-center gap-1.5 rounded-full bg-indigo-50 py-1 pr-3 pl-2 text-sm font-semibold text-indigo-900 ring-1 ring-indigo-600/20 ring-inset">
                          <DifficultyIcon level={level} className="size-3.5 shrink-0 text-indigo-800" />
                          <span className="sr-only">Difficulty: </span>
                          {difficulties[level].label}
                        </p>
                        <Sub className="mt-3 text-xl font-semibold tracking-tight text-pretty text-neutral-950">{trail.name}</Sub>
                        {trail.park ? <p className="mt-1 text-sm leading-6 text-neutral-600">{trail.park}</p> : null}
                      </div>

                      <div className={rows ? "lg:col-span-8" : "mt-5 flex flex-1 flex-col"}>
                        {facts.length ? (
                          <dl className={`grid grid-cols-1 gap-x-6 gap-y-2.5 text-sm leading-6 ${rows ? "sm:grid-cols-2 xl:grid-cols-3" : "min-[400px]:grid-cols-2"}`}>
                            {facts.map((f) => (
                              // dt and dd must be direct children of the row div; the icon sits in the dt.
                              <div key={f.term} className="relative min-w-0 pl-6">
                                <dt className="text-xs text-neutral-600">
                                  <span className="absolute top-1 left-0">
                                    <LineIcon d={f.icon} />
                                  </span>
                                  {f.term}
                                </dt>
                                <dd className="font-medium break-words text-neutral-950">{f.value}</dd>
                              </div>
                            ))}
                          </dl>
                        ) : null}

                        {trail.accessibility ? (
                          <div className="mt-5 flex gap-3 rounded-xl bg-neutral-50 p-4 ring-1 ring-neutral-200 ring-inset">
                            <LineIcon d={icons.accessible} className="mt-0.5 size-5 shrink-0 text-indigo-700" />
                            <div className="min-w-0">
                              <p className="text-sm font-semibold text-neutral-950">Accessibility</p>
                              <p className="mt-1 text-sm leading-6 text-pretty text-neutral-700">{trail.accessibility}</p>
                            </div>
                          </div>
                        ) : null}

                        {trail.trailhead ? (
                          <p className="mt-4 flex items-start gap-2 text-sm leading-6 text-neutral-700">
                            <span className="mt-1">
                              <LineIcon d={icons.parking} />
                            </span>
                            <span className="min-w-0">
                              <span className="font-semibold text-neutral-950">Trailhead: </span>
                              {trail.trailhead}
                            </span>
                          </p>
                        ) : null}

                        {trail.mapHref || trail.gpxHref ? (
                          <div className={`flex flex-wrap gap-x-5 gap-y-1 ${rows ? "mt-3" : "mt-auto pt-3"}`}>
                            {trail.mapHref ? (
                              <a
                                href={trail.mapHref}
                                className={`inline-flex min-h-11 items-center gap-1.5 rounded text-sm font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 ${focusRing}`}
                              >
                                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0">
                                  <path fillRule="evenodd" d="M8.157 2.176a1.5 1.5 0 0 0-1.147 0l-4.084 1.69A1.5 1.5 0 0 0 2 5.25v10.877a1.5 1.5 0 0 0 2.074 1.386l3.51-1.452 4.26 1.762a1.5 1.5 0 0 0 1.146 0l4.083-1.69A1.5 1.5 0 0 0 18 14.75V3.872a1.5 1.5 0 0 0-2.073-1.386l-3.51 1.452-4.26-1.762ZM7.58 5a.75.75 0 0 1 .75.75v6.5a.75.75 0 0 1-1.5 0v-6.5A.75.75 0 0 1 7.58 5Zm5.59 2.75a.75.75 0 0 0-1.5 0v6.5a.75.75 0 0 0 1.5 0v-6.5Z" clipRule="evenodd" />
                                </svg>
                                Trail map<span className="sr-only"> for {trail.name}</span>
                              </a>
                            ) : null}
                            {trail.gpxHref ? (
                              <a
                                href={trail.gpxHref}
                                download
                                className={`inline-flex min-h-11 items-center gap-1.5 rounded text-sm font-semibold text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:decoration-indigo-700 ${focusRing}`}
                              >
                                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-4 shrink-0">
                                  <path d="M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z" />
                                  <path d="M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z" />
                                </svg>
                                GPX file<span className="sr-only"> for {trail.name}</span>
                              </a>
                            ) : null}
                          </div>
                        ) : null}
                      </div>
                    </article>
                  </li>
                );
              })}
            </ul>
          ) : null}

          {footnote ? <p className="mt-10 max-w-3xl text-sm leading-6 text-pretty text-neutral-600">{footnote}</p> : null}
        </div>
      </section>
    );
  },
};
```
