Skip to content

fix(i18n): double locale prefix in Governance TOC links #53

@JohnRDOrazio

Description

@JohnRDOrazio

Symptom

On https://catholicdigitalcommons.org/it/governance, the four section cards link to URLs with a doubled locale, e.g.:

  • "Governanza del Progetto" → https://catholicdigitalcommons.org/it/it/governance-2/governanza-del-progetto

(the /it/it/ is wrong; the correct URL would be /it/governance-2/governanza-del-progetto)

Root cause

components/sections/GovernanceTOC.tsx:37 does:

<Link key={page.slug} href={page.uri} ... />

page.uri comes from getChildPages → GraphQL pages { nodes { uri } } (lib/wordpress/queries.ts:403). With Polylang in directory mode, this URI already includes the language prefix (/it/governance-2/governanza-del-progetto). The <Link> from @/src/i18n/navigation (which wraps next-intl's navigation with localePrefix: 'as-needed' from src/i18n/routing.ts:7) then prepends the locale again.

Suggested fix

Don't trust Polylang's uri field in headless mode — it describes how the URL would look on a Polylang-rendered front-end, not on Next.js. Use the slug chain (or the leaf slug plus the parent context) and let next-intl add the locale prefix exactly once.

Concretely:

  • Drop uri from GET_CHILD_PAGES in lib/wordpress/queries.ts.
  • Have the catch-all page (app/[lang]/[[...slug]]/page.tsx) compose the path from its own URL segments + each child's slug, e.g. [...currentSlug, child.slug].join('/').
  • Pass that to <Link href=...>.

Related

This is the same misuse pattern as the sitemap bug (separate issue) and is part of the broader "translated slugs aren't actually consumed" gap (Header navigation issue, also separate).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions