Skip to content

Give the legal pages one header with a checked Last updated date - #1136

Open
noahkhomer18 wants to merge 2 commits into
richshaw:mainfrom
noahkhomer18:refactor/1130-legal-header
Open

noahkhomer18 wants to merge 2 commits into
richshaw:mainfrom
noahkhomer18:refactor/1130-legal-header

Conversation

@noahkhomer18

Copy link
Copy Markdown
Contributor

Closes #1130.

The cookies and terms pages typed their formatted "Last updated" date by hand, while privacy kept an ISO constant and checked it with formatDay. Now all three go through one header.

  • src/app/(site)/(legal)/legal-header.tsx holds formatDay (moved from the privacy page) and LegalHeader({ title, updated }), which renders the existing <header> markup with formatDay(updated).
  • Cookies and terms each get a PAGE_UPDATED ISO constant (2026-11-12, 2026-10-31) and one <LegalHeader … />.
  • Privacy keeps its later-of comparison on the ISO strings and passes the winner to LegalHeader. It still checks the site's lastUpdated even when its own date is later, in the page body, so the existing PrivacyPage() throw tests see it.
  • formatDay takes an optional source for the error, so the privacy additions still name lastUpdated in src/lib/privacy-additions.ts (the wording privacy/page.test.tsx expects) and a page's own date names PAGE_UPDATED.

Rendered output is unchanged. I rendered each page with jsdom on main (09127b0) and on this branch and compared innerHTML: privacy (no additions), privacy with a later additions date, cookies and terms are byte-for-byte identical.

Tests (legal-header.test.tsx): each page shows the formatted form of its own PAGE_UPDATED (read from its source, since Next.js allows a page no extra exports, with the additions mocked to null so a deployment's own file can't change the date), no page source contains a hand-typed Last updated:, and formatDay formats real days and refuses 2026-02-30, 2026-13-01, 2026-00-10, 1/12/2026, 2026-1-01 and '', naming the source. To check they bite, I broke one thing at a time: the header ignoring the page's date, terms going back to a hand-typed header, formatDay accepting 30 February, and privacy no longer checking the site's date each fail tests.

Checks: pnpm lint, pnpm format:check, pnpm typecheck and pnpm knip pass, and the legal pages' 32 tests pass. In the full pnpm test, 2 tests in src/i18n/testing/catalog-check.test.ts fail on my machine on main as well (Node 24.22, ICU 78.3 / CLDR 48 plural rules), while CI on main is green, so it's my local Node rather than this change.

noahkhomer18 and others added 2 commits November 26, 2026 11:37
Cookies and terms typed their formatted date by hand, so a mistyped bump
went unnoticed. formatDay moves from the privacy page to legal-header.tsx
with a LegalHeader component that renders the existing markup. Cookies and
terms keep a PAGE_UPDATED constant like privacy, and privacy still checks
the site's own date even when its own is later.

Signed-off-by: Noah Khomer <108771853+noahkhomer18@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The cookies and terms pages hand-type their "Last updated" date, while the privacy page formats and checks an ISO date

2 participants