Skip to content

Conversation

@HazAT
Copy link
Member

@HazAT HazAT commented Oct 29, 2025

  • Added a helper function to resolve Open Graph image URLs based on various conditions, including manual overrides and fallback mechanisms.
  • Integrated the new function into the metadata generation process to prioritize custom images, the first image from content, or a default image.
  • Introduced a new remark plugin to extract the first image from markdown content for use in Open Graph metadata.
  • Updated frontmatter type definitions to include an optional og_image field for custom Open Graph images.

- Added a helper function to resolve Open Graph image URLs based on various conditions, including manual overrides and fallback mechanisms.
- Integrated the new function into the metadata generation process to prioritize custom images, the first image from content, or a default image.
- Introduced a new remark plugin to extract the first image from markdown content for use in Open Graph metadata.
- Updated frontmatter type definitions to include an optional `og_image` field for custom Open Graph images.
@vercel
Copy link

vercel bot commented Oct 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
develop-docs Ready Ready Preview Comment Oct 30, 2025 1:39pm
sentry-docs Ready Ready Preview Comment Oct 30, 2025 1:39pm

…age field

- Moved the firstImage property to the end of the SlugFile type definition for better organization.
- Updated the remarkExtractFirstImage function to return undefined when no image is found, improving clarity in the image extraction logic.
@codecov
Copy link

codecov bot commented Oct 29, 2025

Bundle Report

Changes will increase total bundle size by 126.24kB (0.54%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-client-array-push 10.16MB -6 bytes (-0.0%) ⬇️
sentry-docs-server-cjs 13.11MB 126.25kB (0.97%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.78MB -0.0%
../instrumentation.js -3 bytes 1.1MB -0.0%
9523.js -3 bytes 1.08MB -0.0%
../app/[[...path]]/page.js.nft.json 41.97kB 901.81kB 4.88%
../app/platform-redirect/page.js.nft.json 41.97kB 901.72kB 4.88%
../app/sitemap.xml/route.js.nft.json 41.97kB 898.95kB 4.9%
../app/[[...path]]/page.js 313 bytes 615.64kB 0.05%
9567.js 29 bytes 22.21kB 0.13%

Files in ../app/[[...path]]/page.js:

  • ./app/[[...path]]/page.tsx → Total Size: 12.2kB

App Routes Affected:

App Route Size Change Total Size Change (%)
/[[...path]] 313 bytes 3.36MB 0.01%
view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 882.71kB -0.0%
static/chunks/8321-*.js -3 bytes 425.87kB -0.0%
server/middleware-*.js 6.46kB 7.46kB 645.5% ⚠️
server/middleware-*.js -6.46kB 1.0kB -86.59%
static/l6lC4rWfy3r_bLsoLROkj/_buildManifest.js (New) 684 bytes 684 bytes 100.0% 🚀
static/l6lC4rWfy3r_bLsoLROkj/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/dZr86wU9A0THVzowjLBNd/_buildManifest.js (Deleted) -684 bytes 0 bytes -100.0% 🗑️
static/dZr86wU9A0THVzowjLBNd/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️

- Added directory existence check for mdx-images to prevent errors when accessing images.
- Improved error handling and logging for image resolution failures.
- Updated asset caching logic to handle Vercel deployment scenarios, ensuring images are correctly managed in read-only environments.
- Enhanced overall robustness of the image resolution process by returning null when images are not found, allowing for fallback to default images.
- Refactored the `resolveOgImageUrl` function to remove asynchronous operations, improving performance and clarity.
- Updated the logic to handle image paths more efficiently, ensuring that fallback mechanisms are in place when images are not found.
- Enhanced the integration of the image resolution function within the metadata generation process, streamlining the handling of custom and default images.
cursor[bot]

This comment was marked as outdated.

- Changed the way metafile is accessed in the getFileBySlug function to ensure type safety by casting the result to 'any'.
- Improved clarity by defining the metafile structure explicitly, enhancing maintainability and reducing potential runtime errors.
…eBySlug function

- Enhanced the logic to detect Vercel and AWS Lambda environments, ensuring proper usage of the /tmp directory to avoid read-only file system errors.
- Updated comments for clarity regarding the deployment scenarios and the handling of output directories.
and add a script to copy images into the public folder
@codeowner-assignment codeowner-assignment bot requested a review from a team October 30, 2025 10:17
cursor[bot]

This comment was marked as outdated.

- Updated the logic to always use the public/mdx-images directory during build, removing the conditional checks for Vercel and AWS Lambda environments.
- Improved comments for clarity regarding directory creation and asset copying, ensuring that images are assumed to exist from build time.
- Streamlined cache checking logic by removing unnecessary runtime checks, enhancing maintainability.
- Introduced a README file in the public/og-images directory to document the generation and usage of Open Graph images.
- Updated the addOgImageToFile function to always copy the source image, ensuring that images are regenerated on each build, even if frontmatter already exists.
- Enhanced error handling to track and report any image copy errors during the generation process.
- Added 'public/og-images/**/*' to the outputFileTracingExcludes for both '/platform-redirect' and sitemap.xml paths, ensuring proper handling of Open Graph images during the build process.

// Simple regex to find markdown images ![alt](path)
const IMAGE_REGEX = /!\[([^\]]*)\]\(([^)]+)\)/;

Copy link

Choose a reason for hiding this comment

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

Bug: Regex Fails with Parentheses in Image Paths

The IMAGE_REGEX in add-og-images.ts uses [^)]+ to capture image paths, which stops at the first closing parenthesis. This causes image paths containing parentheses to be truncated, preventing the script from finding and copying the correct image file.

Fix in Cursor Fix in Web

@HazAT HazAT merged commit 0cbac5f into master Oct 30, 2025
15 checks passed
@HazAT HazAT deleted the feat-og-image branch October 30, 2025 20:56
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.

2 participants