Skip to content

feat(GAT-5649): Add generated opengraph metadata - #1758

Merged
philreekshdr merged 3 commits into
devfrom
feat/GAT-5649
Nov 20, 2026
Merged

philreekshdr merged 3 commits into
devfrom
feat/GAT-5649

Conversation

@philreekshdr

Copy link
Copy Markdown
Collaborator

Disclaimer: AI (Claude) was used to assist with implementing and documenting the changes in this PR.

Screenshots / videos (if relevant)

image image image

Describe your changes

Public entity pages (datasets, collections, tools, data uses, publications, data custodians, custodian networks, and news and event articles) now build their metadata from the entity itself.

Shared links show the real name and a clean description instead of a generic title. Every page now emits canonical, Open Graph and Twitter card tags through metaData(). Descriptions are cleaned of HTML, rich-text JSON and Markdown, cut to 160 characters at a word boundary, and fall back to the site description when empty.

A new /api/og route renders a branded 1200×630 share card with the page title and, where the entity has one, its logo. Logos are only fetched from the hosts next/image already allows, and visitor cookies are never forwarded. Cards are cached for a day unless something failed to load. metadataBase comes from NEXT_PUBLIC_GATEWAY_URL so crawlers get absolute URLs.

The unused gateway-white-logo.svg is removed, and the details are documented in docs/ARCHITECTURE/page-metadata.md.

Issue ticket link

https://hdruk.atlassian.net/browse/GAT-5649

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have added appropriate unit tests / e2e tests (where relevant)
  • I have created mocks for api endpoints (where appropriate)
  • The interface is responsive (where ticket is relevant)
  • The interface is at least AA (where ticket is relevant)
  • Commits are described as "(chore|fix|feature|test|maintenance): description"

@github-actions

Copy link
Copy Markdown

⚠️ This PR touches the third-party widget embed surface

Widgets generated by the widget creator are embedded in external
websites we do not control
. A breaking change here fails silently
on those sites.

  • The widget contract tests (*.contract.test.*, widget-embed.cy.ts)
    must pass.
  • If a contract change is intentional, flag the change in release
    notes, and notify teams with active widgets before release.

@gh-actions-pipelines-app

Copy link
Copy Markdown

🎉 Great job! Your PR title follows the correct format. 🚀

@HDRUK-Claude HDRUK-Claude left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Review-E automated review

The metadata refactor and the entity page changes are low risk. Metadata fetches reuse the same memoised calls as the page bodies, and the entity-image lookup is limited by an allowlist. The main concern is the new unauthenticated /api/og route: it renders and publicly caches any title it is given.

Findings: 🟠 Medium × 1

Automated review by Claude. Advisory only. A human approval is still required.

Comment thread src/app/api/og/route.tsx Resolved

@HDRUK-Claude HDRUK-Claude left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Review-E automated review

The new commits are low risk. They stop the [locale] layout from passing Open Graph and Twitter tags down to every page: it now exports defaultMetadata, and metaData() sets openGraph and twitter to null whenever noFollowRobots is passed. Every caller I found passes either the default or noFollowRobots, so the reference check works as intended. The earlier finding about arbitrary ?title= text on the cached /api/og card is unchanged.

No logic, breaking-change, security or performance concerns found.

Automated review by Claude. Advisory only. A human approval is still required.

@HDRUK-Claude HDRUK-Claude left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Review-E automated review

Low risk. The earlier finding is fixed: /api/og now ignores ?title= and only accepts ?type=&id=, getting the title and image from the same PAGE_TYPES loaders the pages use, so a card can only show what the public page shows. The new visibility checks (isActive, the CMS category check) match each page's notFound() condition, and getNewsArticle/getEventArticle are wrapped in React cache() so the CMS is queried once per request. I found no new bugs, breaking changes or data leaks in the new commits.

No logic, breaking-change, security or performance concerns found.

Automated review by Claude. Advisory only. A human approval is still required.

@philreekshdr
philreekshdr merged commit c7ffb0c into dev Nov 20, 2026
4 checks passed
@philreekshdr
philreekshdr deleted the feat/GAT-5649 branch November 20, 2026 15:09

This branch was successfully deployed

2 active deployments
dev — 5f041d6a Deployed Nov 20, 2026 by philreekshdr via test #6459
cypress_dev — 5f041d6a Deployed Nov 20, 2026 by philreekshdr via e2e-tests #716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants