# Add the "Language Links" block to this P1 project

Add a Puck component from P1 Blocks (https://p1-blocks.prolificdigital.io/blocks/language-links) to this Pantheon Content Publisher (P1) Next.js project. Links to translated versions of a page, each named in its own language with correct lang and hreflang.

## Steps

1. Create `components/puck/language-links-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 { languageLinksBlock } from "./components/puck/language-links-block";`
3. Register it under `components` as `LanguageLinksBlock: languageLinksBlock`.
4. Add `"LanguageLinksBlock"` 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/language-links-block.tsx`

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

/**
 * Language Links — "This page in other languages", with each language written in its own
 * script and marked with lang and hreflang so screen readers pronounce it correctly.
 * Register: `LanguageLinksBlock: languageLinksBlock` in puck.config.tsx.
 */

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

export type LanguageLinksProps = {
  heading: string;
  headingLevel: Heading;
  intro: string;
  layout: "cards" | "bar";
  languages: { nativeName: string; englishName: string; code: string; href: string }[];
};

const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600";
const rtl = new Set(["ar", "he", "fa", "ur", "ps", "yi", "dv", "ckb"]);
const dirOf = (code: string) => (rtl.has((code || "").toLowerCase().split("-")[0]) ? "rtl" : "ltr");

export const languageLinksBlock: ComponentConfig<LanguageLinksProps> = {
  label: "Language Links",
  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: "Shown in the cards layout only. Leave blank to hide it." } },
    layout: {
      type: "radio",
      label: "Layout",
      options: [
        { label: "Cards", value: "cards" },
        { label: "Slim bar", value: "bar" },
      ],
      metadata: { help: "Cards suit a full section. The slim bar fits at the top or bottom of a page." },
    },
    languages: {
      type: "array",
      label: "Languages",
      min: 1,
      max: 16,
      getItemSummary: (item) => (item?.nativeName ? `${item.nativeName}${item.code ? ` (${item.code})` : ""}` : "Language"),
      defaultItemProps: { nativeName: "Español", englishName: "Spanish", code: "es", href: "/es" },
      arrayFields: {
        nativeName: { type: "text", label: "Name in that language", metadata: { help: "Write it the way speakers do, like Español, 中文 or العربية." } },
        englishName: { type: "text", label: "Name in English", metadata: { help: "Shown smaller underneath. Leave blank to hide it." } },
        code: {
          type: "text",
          label: "Language code",
          metadata: { help: "The standard code, like es, vi, zh-Hans or ar. Screen readers use it to switch pronunciation, and search engines to match the page." },
        },
        href: { type: "text", label: "Link", metadata: { help: "The translated version of this page." } },
      },
    },
  },
  defaultProps: {
    heading: "This page in other languages",
    headingLevel: "h2",
    intro: "Translations are reviewed by staff who speak each language. Call (513) 555-0187 to request a free interpreter in your language.",
    layout: "cards",
    languages: [
      { nativeName: "Español", englishName: "Spanish", code: "es", href: "/es/programs" },
      { nativeName: "Tiếng Việt", englishName: "Vietnamese", code: "vi", href: "/vi/programs" },
      { nativeName: "中文", englishName: "Chinese (Simplified)", code: "zh-Hans", href: "/zh-hans/programs" },
      { nativeName: "العربية", englishName: "Arabic", code: "ar", href: "/ar/programs" },
      { nativeName: "Kreyòl ayisyen", englishName: "Haitian Creole", code: "ht", href: "/ht/programs" },
      { nativeName: "한국어", englishName: "Korean", code: "ko", href: "/ko/programs" },
    ],
  },
  render: ({ id, heading, headingLevel, intro, layout, languages }) => {
    const H = headingLevel || "h2";
    const list = (languages ?? []).filter((l) => l?.nativeName);
    if (!list.length) return <></>;
    const headingId = `lang-links-${id}`;

    if (layout === "bar") {
      return (
        <nav aria-labelledby={heading ? headingId : undefined} aria-label={heading ? undefined : "Other languages"} className="border-y border-neutral-200 bg-neutral-50 px-4 py-2 sm:px-6 lg:px-8">
          <div className="mx-auto flex max-w-7xl flex-col gap-x-6 sm:flex-row sm:items-center">
            {heading ? (
              <H id={headingId} className="flex shrink-0 items-center gap-2 pt-2 text-sm font-semibold text-neutral-950 sm:pt-0">
                <svg aria-hidden="true" viewBox="0 0 20 20" fill="currentColor" className="size-5 text-indigo-600">
                  <path d="M7.75 2.75a.75.75 0 0 0-1.5 0v1.258a32.987 32.987 0 0 0-3.599.278.75.75 0 1 0 .198 1.487A31.545 31.545 0 0 1 8.7 5.545 19.381 19.381 0 0 1 7 9.56a19.418 19.418 0 0 1-1.002-2.05.75.75 0 0 0-1.384.577 20.935 20.935 0 0 0 1.492 2.91 19.613 19.613 0 0 1-3.828 4.154.75.75 0 1 0 .945 1.164A21.116 21.116 0 0 0 7 12.331c.095.132.192.262.29.391a.75.75 0 0 0 1.194-.91c-.204-.266-.4-.538-.59-.815a20.888 20.888 0 0 0 2.333-5.332c.31.031.618.068.924.108a.75.75 0 0 0 .198-1.487 32.832 32.832 0 0 0-3.599-.278V2.75Z" />
                  <path fillRule="evenodd" d="M13 8a.75.75 0 0 1 .671.415l4.25 8.5a.75.75 0 1 1-1.342.67L15.787 16h-5.573l-.793 1.585a.75.75 0 1 1-1.342-.67l4.25-8.5A.75.75 0 0 1 13 8Zm2.037 6.5L13 10.427 10.964 14.5h4.073Z" clipRule="evenodd" />
                </svg>
                {heading}
              </H>
            ) : null}
            <ul role="list" className="flex flex-wrap gap-x-1">
              {list.map((l, i) => (
                <li key={`${l.code}-${i}`}>
                  <a
                    href={l.href || "#"}
                    hrefLang={l.code || undefined}
                    lang={l.code || undefined}
                    dir={dirOf(l.code)}
                    className={`inline-flex min-h-11 items-center rounded px-2 text-sm font-medium text-indigo-700 underline decoration-indigo-300 underline-offset-4 hover:text-indigo-900 hover:decoration-indigo-700 ${focusRing}`}
                  >
                    {l.nativeName}
                  </a>
                </li>
              ))}
            </ul>
          </div>
        </nav>
      );
    }

    return (
      <section aria-labelledby={heading ? headingId : 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-5xl">
          {heading || intro ? (
            <div className="max-w-2xl">
              {heading ? (
                <H id={headingId} className="text-2xl font-semibold tracking-tight text-balance text-neutral-950 sm:text-3xl">
                  {heading}
                </H>
              ) : null}
              {intro ? <p className="mt-3 text-base leading-7 text-pretty text-neutral-600">{intro}</p> : null}
            </div>
          ) : null}
          <ul role="list" className={`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 ${heading || intro ? "mt-8" : ""}`}>
            {list.map((l, i) => (
              <li key={`${l.code}-${i}`}>
                <a
                  href={l.href || "#"}
                  hrefLang={l.code || undefined}
                  className={`group flex min-h-11 items-center justify-between gap-4 rounded-xl bg-white px-5 py-4 ring-1 ring-neutral-200 transition hover:-translate-y-0.5 hover:shadow-md hover:ring-indigo-300 ${focusRing}`}
                >
                  <span className="min-w-0">
                    <span lang={l.code || undefined} dir={dirOf(l.code)} className="block text-lg font-semibold text-neutral-950 group-hover:text-indigo-700">
                      {l.nativeName}
                    </span>
                    {l.englishName ? <span className="mt-0.5 block text-sm text-neutral-600">{l.englishName}</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="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>
              </li>
            ))}
          </ul>
        </div>
      </section>
    );
  },
};
```
