Refactor metadata architecture for SEO with dynamic OpenGraph images#1037
Refactor metadata architecture for SEO with dynamic OpenGraph images#1037
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
- Created reusable OpenGraphImage component for consistent OG images - Enhanced root layout with comprehensive metadata, OpenGraph, and Twitter cards - Added OpenGraph images for all about pages (/about, /about/api, /about/source-trust) - Implemented dynamic OpenGraph images for diff pages showing stats (additions, deletions, files) - Added provenance and trusted publisher badges to diff OpenGraph images - Updated all page metadata with improved descriptions and OpenGraph data Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
- Add display: flex to all divs and spans to satisfy Next.js ImageResponse requirements - Tested dynamic OG images showing stats and badges correctly - All validation checks pass (lint, typecheck, tests, build) Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
|
@copilot in trying to evaluate if the og image for the diff page is working, but it's hard because its hardcoded to npm-diff.app, which is probably good once we merge it, but until then, it would be good if the url for the og image was relative. Not sure if the diffpage is hardcoding or if it is metadata base, but please look into it. Furthermore, can you explain all the metadata you've added, and motivating why. |
Use VERCEL_URL for preview deployments, localhost for development, and production URL as fallback. This allows OpenGraph images to work in all environments without hardcoding to production. Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
Fixed the hardcoded URL issue in commit 26769cc. The
This ensures OpenGraph images resolve to the correct environment URL for testing. Metadata Explanation: Root Layout (
About Pages:
Diff Pages (
All metadata follows OpenGraph Protocol and Twitter Card specs for optimal social media presentation and search engine indexing. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Co-authored-by: oBusk <13413409+oBusk@users.noreply.github.com>
Current metadata is minimal and lacks OpenGraph images. About pages have inconsistent implementations, diff pages have no social preview, and app-wide metadata isn't properly inherited.
Changes
Reusable OpenGraph Component
src/app/_components/OpenGraphImage.tsxaccepting tag, title, and icon propsRoot Layout Metadata Enhancement
metadataBasethat adapts to environment (Vercel preview, localhost development, or production)About Pages
/about: Info icon with feature overview/about/api: Code brackets icon for API documentation/about/source-trust: Refactored to use new component (shield icon)Dynamic Diff Page OpenGraph
/api/-/oggenerates images with diff statistics/api/-/og?parts=react@18.0.0...react@18.3.0Example dynamic image for
ini@5.0.0...6.0.0shows:Metadata Rationale
metadataBase: Resolves relative URLs to absolute URLs for social media crawlers. Now dynamic to support testing in development (
http://localhost:3000), preview deployments (process.env.VERCEL_URL), and production (https://npm-diff.app).description: Expanded with SEO keywords like "bundle size changes", "provenance", "trusted publishing", and "safer dependency upgrades" for improved search engine visibility.
keywords: Array of relevant search terms (npm, diff, package comparison, dependency audit, provenance, trusted publishing) for better search engine indexing.
authors & creator: Attribution metadata for search engines and social platforms.
openGraph: Default metadata with
type,locale,url,siteNamefor rich social sharing previews across all pages.twitter: Twitter-specific metadata with
card: "summary_large_image"for large preview cards andcreator: "@oBusk"for attribution.All page-specific metadata includes tailored descriptions and OpenGraph images for targeted SEO and optimal social media presentation.
Technical Notes
<div>and<span>elements require explicitdisplay: flexfor Next.js ImageResponseruntime = "nodejs"export (incompatible with Next.js 16 cacheComponents)metadataBaseuses environment detection for seamless testing across deployment environmentsOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.