Skip to content

Extract app metadata into dedicated files and add OG image tests#2446

Open
andrew-bierman wants to merge 1 commit into
developmentfrom
codex/fix-open-graph-images-and-add-tests
Open

Extract app metadata into dedicated files and add OG image tests#2446
andrew-bierman wants to merge 1 commit into
developmentfrom
codex/fix-open-graph-images-and-add-tests

Conversation

@andrew-bierman

@andrew-bierman andrew-bierman commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Motivation

  • Centralize and reuse page metadata by moving large inline metadata objects out of layout.tsx into dedicated metadata.ts modules.
  • Ensure Open Graph and Twitter image URLs are absolute and correctly set based on site configuration by adding tests that assert those values.

Description

  • Added apps/landing/app/metadata.ts and apps/guides/app/metadata.ts that export the metadata: Metadata objects and define absolute OG/Twitter image URLs using new URL(..., siteConfig.url).toString().
  • Updated apps/landing/app/layout.tsx and apps/guides/app/layout.tsx to import the metadata as appMetadata and re-export it via export const metadata = appMetadata;, removing the previous inline metadata definitions.
  • Added Vitest unit tests layout.og-metadata.test.ts in both apps/landing/app and apps/guides/app to assert the OG image object contains the expected absolute url, width, height, and alt, and that twitter.images equals the absolute URL.

Testing

  • Added and ran Vitest tests apps/landing/app/layout.og-metadata.test.ts and apps/guides/app/layout.og-metadata.test.ts to validate absolute OG/Twitter image metadata, and the tests passed.

Codex Task

Summary by CodeRabbit

  • Tests

    • Added validation tests for page metadata configuration to ensure accurate Open Graph and Twitter card data.
  • Chores

    • Consolidated metadata configuration into dedicated files for improved maintainability and consistency across applications.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Deploying packrat-guides with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3565de0
Status:🚫  Build failed.

View logs

@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Metadata object configurations are extracted from guides and landing layout files into dedicated modules. Each app receives a new metadata.ts file defining SEO, Open Graph, Twitter, and icon settings with absolute URLs computed from siteConfig. Layout files simplify to import and re-export the new modules. Tests validate image URL construction.

Changes

Metadata extraction across guides and landing apps

Layer / File(s) Summary
Guides metadata extraction
apps/guides/app/metadata.ts, apps/guides/app/layout.tsx
New metadata.ts module defines Next.js metadata with title, description, keywords, authors, metadataBase, Open Graph, Twitter, and icon URLs computed from siteConfig.url. Layout file imports and re-exports it.
Landing metadata extraction
apps/landing/app/metadata.ts, apps/landing/app/layout.tsx
New metadata.ts module defines Next.js metadata with SEO fields and dynamically computed absolute Open Graph image URL from siteConfig.ogImage and siteConfig.url. Layout file imports and re-exports it.
Metadata validation tests
apps/guides/app/layout.og-metadata.test.ts, apps/landing/app/layout.og-metadata.test.ts
Test suites verify that Open Graph and Twitter image metadata are constructed as absolute URLs with correct dimensions and alt text derived from siteConfig.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • PackRat-AI/PackRat#2428: Extracts guides/landing Open Graph + Twitter image metadata into dedicated modules and adds Vitest assertions for absolute image URLs.
  • PackRat-AI/PackRat#2427: Corresponding changes across the same guides/landing metadata layout and metadata test files.
  • PackRat-AI/PackRat#2441: Updates guides/landing metadata OG/Twitter image paths and aligns corresponding metadata tests with the image URL expectations.

Suggested labels

web

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: extracting metadata into dedicated files and adding OG image tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-open-graph-images-and-add-tests
⚔️ Resolve merge conflicts
  • Resolve merge conflict in branch codex/fix-open-graph-images-and-add-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

Copy link
Copy Markdown
Contributor

Deploying packrat-landing with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3565de0
Status: ✅  Deploy successful!
Preview URL: https://470932f5.packrat-landing.pages.dev
Branch Preview URL: https://codex-fix-open-graph-images.packrat-landing.pages.dev

View logs

@andrew-bierman andrew-bierman marked this pull request as ready for review June 5, 2026 05:35
Copilot AI review requested due to automatic review settings June 5, 2026 05:35

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/landing/app/metadata.ts`:
- Line 42: The manifest URL is built via string interpolation which can produce
double slashes; replace the interpolated manifest:
`${siteConfig.url}/site.webmanifest` with construction using new URL so it
correctly resolves regardless of trailing slash (e.g., use new
URL('/site.webmanifest', siteConfig.url).toString() or .href), mirroring the
approach used elsewhere in this file (see other usages referencing
siteConfig.url).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7a1b9a6a-2599-4882-a21b-b68dbd9e2530

📥 Commits

Reviewing files that changed from the base of the PR and between c66e287 and 3565de0.

📒 Files selected for processing (6)
  • apps/guides/app/layout.og-metadata.test.ts
  • apps/guides/app/layout.tsx
  • apps/guides/app/metadata.ts
  • apps/landing/app/layout.og-metadata.test.ts
  • apps/landing/app/layout.tsx
  • apps/landing/app/metadata.ts

shortcut: '/favicon-16x16.png',
apple: '/apple-touch-icon.png',
},
manifest: `${siteConfig.url}/site.webmanifest`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use new URL() for consistent URL construction.

String interpolation can produce malformed URLs if siteConfig.url has a trailing slash (resulting in //site.webmanifest). Use the same pattern as lines 23 and 35 for consistency and correctness.

🔧 Proposed fix
-  manifest: `${siteConfig.url}/site.webmanifest`,
+  manifest: new URL('/site.webmanifest', siteConfig.url).toString(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
manifest: `${siteConfig.url}/site.webmanifest`,
manifest: new URL('/site.webmanifest', siteConfig.url).toString(),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/landing/app/metadata.ts` at line 42, The manifest URL is built via
string interpolation which can produce double slashes; replace the interpolated
manifest: `${siteConfig.url}/site.webmanifest` with construction using new URL
so it correctly resolves regardless of trailing slash (e.g., use new
URL('/site.webmanifest', siteConfig.url).toString() or .href), mirroring the
approach used elsewhere in this file (see other usages referencing
siteConfig.url).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the Next.js metadata definitions for the Landing and Guides apps by extracting them into dedicated app/metadata.ts modules, and adds Vitest checks intended to assert absolute Open Graph / Twitter image URLs.

Changes:

  • Added app/metadata.ts modules for Landing and Guides and re-exported them from layout.tsx.
  • Added explicit openGraph.images and twitter.images entries (now absolute URLs).
  • Added Vitest unit tests asserting OG/Twitter image metadata structure and URLs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
apps/landing/app/metadata.ts New centralized Landing metadata (now includes explicit OG/Twitter image URLs).
apps/landing/app/layout.tsx Re-exports extracted Landing metadata.
apps/landing/app/layout.og-metadata.test.ts Adds Landing metadata assertions for OG/Twitter image URLs.
apps/guides/app/metadata.ts New centralized Guides metadata (includes explicit OG/Twitter image URLs).
apps/guides/app/layout.tsx Re-exports extracted Guides metadata.
apps/guides/app/layout.og-metadata.test.ts Adds Guides metadata assertions for OG/Twitter image URLs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +26
images: [
{
url: new URL(siteConfig.ogImage, siteConfig.url).toString(),
width: 1200,
height: 630,
alt: siteConfig.name,
Comment on lines +30 to +36
twitter: {
card: 'summary_large_image',
title: siteConfig.name,
description: siteConfig.description,
creator: siteConfig.twitterHandle,
images: [new URL(siteConfig.ogImage, siteConfig.url).toString()],
},
Comment on lines +6 to +8
it('sets absolute og/twitter image metadata', () => {
const expected = new URL(siteConfig.ogImage, siteConfig.url).toString();
expect(metadata.openGraph?.images?.[0]).toMatchObject({
Comment on lines +1 to +3
import { describe, expect, it } from 'vitest';
import { siteConfig } from '../config/site';
import { metadata } from './metadata';
Comment on lines +1 to +3
import { describe, expect, it } from 'vitest';
import { siteConfig } from '../lib/config';
import { metadata } from './metadata';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants