Skip to content

refactor: clean root metadata - remove generator, add metadataBase, OG and twitter defaults - #1059

Merged
greatest0fallt1me merged 2 commits into
Predictify-org:mainfrom
Ade-Pheebs:refactor/1015-clean-root-metadata
Nov 23, 2026
Merged

greatest0fallt1me merged 2 commits into
Predictify-org:mainfrom
Ade-Pheebs:refactor/1015-clean-root-metadata

Conversation

@Ade-Pheebs

Copy link
Copy Markdown
Contributor

refactor: clean root metadata — remove generator, add metadataBase, OG and twitter defaults

Summary

Root metadata in app/layout.tsx had generator: "v0.dev", no metadataBase, no openGraph, and no twitter defaults. Relative OG image URLs would resolve incorrectly without metadataBase. This PR cleans it up using lib/config.ts and lib/seo.ts.

Background

  • export const metadata was an untyped object with generator: "v0.dev".
  • lib/config.ts exports config.app.url and config.app.name.
  • lib/seo.ts exports getBaseUrl() which reads NEXT_PUBLIC_APP_URL dynamically.
  • app/markets/[id]/page.tsx and app/api/og/route.tsx need an absolute base for OG images.
  • No test for layout metadata existed.

Changes

app/metadata.ts (new file)

  • Extracted the metadata object into its own module so it can be unit-tested without importing layout.tsx (which pulls in next/font/google and CSS files)
  • Typed as Metadata from next
  • Removed generator: "v0.dev"
  • Added metadataBase: new URL(getBaseUrl()) — follows NEXT_PUBLIC_APP_URL
  • Added title as an object with default and template: "%s | Predictify"
  • Added openGraph: type: "website", siteName from config.app.name, url, title, description, images
  • Added twitter: card: "summary_large_image", title, description, images
  • Kept existing icons unchanged

app/layout.tsx

  • Imports and re-exports metadata from app/metadata.ts
  • Typed viewport export as Viewport from next
  • No other changes — fonts, providers, and body markup untouched

app/__tests__/layout-metadata.test.ts (new file)

  • Imports from app/metadata.ts directly (avoids Next.js font/CSS transform issues in Jest)
  • 16 tests covering:
    • No generator field
    • metadataBase matches default URL when NEXT_PUBLIC_APP_URL is unset
    • metadataBase follows NEXT_PUBLIC_APP_URL when set
    • metadataBase handles trailing slash in NEXT_PUBLIC_APP_URL
    • Title template contains %s | Predictify and has a default
    • openGraph exists with type: "website", siteName, title, description, images
    • twitter exists with card: "summary_large_image", title, description
    • icons preserved

Acceptance Criteria

  • No generator meta
  • metadataBase follows NEXT_PUBLIC_APP_URL
  • Canonical openGraph and twitter defaults exist
  • Existing icons and viewport export unchanged
  • Page-level metadata still overrides defaults (title template mechanism)

Testing

pnpm test -- app/__tests__/layout-metadata.test.ts

Closes #1015

Upstream repo: https://github.com/Predictify-org/predictify-frontend

@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@ruthoreaji-123 is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Ade-Pheebs Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@greatest0fallt1me
greatest0fallt1me merged commit 525c820 into Predictify-org:main Nov 23, 2026
1 of 2 checks passed
@greatest0fallt1me

Copy link
Copy Markdown
Contributor

Thanks @Ade-Pheebs! We resolved the merge conflicts on our side and merged this. 🎉

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.

Clean up root metadata in app/layout.tsx

3 participants