Skip to content

Improve generated Open Graph images - #1080

Open
goldflag wants to merge 1 commit into
masterfrom
codex/improve-docs-og-images
Open

Improve generated Open Graph images#1080
goldflag wants to merge 1 commit into
masterfrom
codex/improve-docs-og-images

Conversation

@goldflag

@goldflag goldflag commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Redesigned generated social preview images with improved layout, typography, branding, and decorative elements.
    • Added page URLs to documentation preview image footers.
    • Added automatic text truncation and responsive title sizing for clearer previews.
    • Ensured preview images display a default “Analytics” label when no label is provided.

@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
rybbit Ready Ready Preview, Comment Jul 18, 2026 10:47pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The OG image generator now accepts page paths, truncates and sizes text dynamically, renders a structured header/content/footer layout, and adds a decorative traffic-line SVG. The route supplies documentation slugs as footer paths.

Changes

OG image generation

Layer / File(s) Summary
Metadata and generator inputs
docs/src/app/og/[...slug]/generate.tsx, docs/src/app/og/[...slug]/route.tsx
The generator accepts an optional path, derives footer text, and receives documentation page slugs from the route when no query title is provided.
Content formatting and layout
docs/src/app/og/[...slug]/generate.tsx
Titles and descriptions are normalized and truncated; title font size is derived from title length; the header and main content use the updated label and styling.
Footer and traffic decoration
docs/src/app/og/[...slug]/generate.tsx
The footer renders the computed URL and a decorative traffic-line SVG with paths and a circle marker.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GET_handler
  participant generateOGImage
  participant OG_image_response
  GET_handler->>generateOGImage: pass page metadata and path
  generateOGImage->>generateOGImage: format text and compute footer URL
  generateOGImage->>OG_image_response: render structured OG image
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: improving the generated Open Graph image rendering and layout.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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/improve-docs-og-images

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.

@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: 2

🧹 Nitpick comments (1)
docs/src/app/og/[...slug]/generate.tsx (1)

67-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Avoid the inset shorthand for better Satori compatibility.

Satori (the layout engine underlying Next.js OG images) can be inconsistent when parsing the inset CSS shorthand, sometimes causing absolutely positioned elements to collapse. It is generally safer to use explicit top, right, bottom, and left coordinates.

🛠️ Proposed refactor
       <div
         style={{
           display: 'flex',
           position: 'absolute',
-          inset: 24,
+          top: 24,
+          right: 24,
+          bottom: 24,
+          left: 24,
           border: '1px solid `#292929`',
           borderRadius: 5,
         }}
       />
🤖 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 `@docs/src/app/og/`[...slug]/generate.tsx around lines 67 - 75, Update the
absolutely positioned div’s style in the OG image generator to replace the inset
shorthand with explicit top, right, bottom, and left properties, preserving the
current 24px spacing on every side and all other styling.
🤖 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 `@docs/src/app/og/`[...slug]/generate.tsx:
- Around line 39-51: Update the footerPath assignment in generateOGImage to
distinguish an undefined path from an empty string: use the docs URL with the
path when path is defined, including "", and retain the base rybbit.com fallback
only when path is undefined.
- Around line 182-202: Update the SVG dimensions in the chart markup around the
TRAFFIC_LINE paths and endpoint circle so the circle at cx="330" with radius 3.5
is fully contained within the viewBox and rendered width; preserve the existing
chart geometry and styling while adding sufficient right-side space to prevent
clipping.

---

Nitpick comments:
In `@docs/src/app/og/`[...slug]/generate.tsx:
- Around line 67-75: Update the absolutely positioned div’s style in the OG
image generator to replace the inset shorthand with explicit top, right, bottom,
and left properties, preserving the current 24px spacing on every side and all
other styling.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: fe983644-cb5d-4bf3-807c-951de03c1abf

📥 Commits

Reviewing files that changed from the base of the PR and between e1dda9b and 0d106a7.

📒 Files selected for processing (2)
  • docs/src/app/og/[...slug]/generate.tsx
  • docs/src/app/og/[...slug]/route.tsx

Comment on lines 39 to +51
export function generateOGImage({
title,
description,
logoSrc,
label,
path,
}: GenerateOGImageProps): ReactElement {
const displayTitle = truncateText(title, 96);
const displayDescription = description
? truncateText(description, 156)
: undefined;
const footerPath = path ? `rybbit.com/docs/${path}` : 'rybbit.com';

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fix the footer URL for the docs root page.

When the image is generated for the root docs page (where path is an empty string ""), the current ternary condition evaluates to falsy and falls back to 'rybbit.com'. It should likely display 'rybbit.com/docs'. Check for undefined explicitly to handle the empty string case properly.

💡 Proposed fix
-  const footerPath = path ? `rybbit.com/docs/${path}` : 'rybbit.com';
+  const footerPath = path !== undefined 
+    ? `rybbit.com/docs${path ? `/${path}` : ''}` 
+    : 'rybbit.com';
📝 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
export function generateOGImage({
title,
description,
logoSrc,
label,
path,
}: GenerateOGImageProps): ReactElement {
const displayTitle = truncateText(title, 96);
const displayDescription = description
? truncateText(description, 156)
: undefined;
const footerPath = path ? `rybbit.com/docs/${path}` : 'rybbit.com';
export function generateOGImage({
title,
description,
logoSrc,
label,
path,
}: GenerateOGImageProps): ReactElement {
const displayTitle = truncateText(title, 96);
const displayDescription = description
? truncateText(description, 156)
: undefined;
const footerPath = path !== undefined
? `rybbit.com/docs${path ? `/${path}` : ''}`
: 'rybbit.com';
🤖 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 `@docs/src/app/og/`[...slug]/generate.tsx around lines 39 - 51, Update the
footerPath assignment in generateOGImage to distinguish an undefined path from
an empty string: use the docs URL with the path when path is defined, including
"", and retain the base rybbit.com fallback only when path is undefined.

Comment on lines +182 to +202
<svg
width="330"
height="44"
viewBox="0 0 330 44"
fill="none"
aria-hidden="true"
>
<path
d={`${TRAFFIC_LINE} L330 44 L0 44 Z`}
fill="rgba(179, 191, 255, 0.07)"
/>
<path
d={TRAFFIC_LINE}
stroke="#b3bfff"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<circle cx="330" cy="5" r="3.5" fill="#b3bfff" />
</svg>
</div>

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Prevent the circle from being clipped by the SVG boundary.

The SVG viewBox and width end at 330. Because the circle is positioned at cx="330" with a radius of 3.5, its right half extends to 333.5 and will be visibly clipped by the default overflow="hidden" behavior of the SVG element.

🎨 Proposed fix to make the overflow visible
         <svg
           width="330"
           height="44"
           viewBox="0 0 330 44"
           fill="none"
           aria-hidden="true"
+          style={{ overflow: 'visible' }}
         >
📝 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
<svg
width="330"
height="44"
viewBox="0 0 330 44"
fill="none"
aria-hidden="true"
>
<path
d={`${TRAFFIC_LINE} L330 44 L0 44 Z`}
fill="rgba(179, 191, 255, 0.07)"
/>
<path
d={TRAFFIC_LINE}
stroke="#b3bfff"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<circle cx="330" cy="5" r="3.5" fill="#b3bfff" />
</svg>
</div>
<svg
width="330"
height="44"
viewBox="0 0 330 44"
fill="none"
aria-hidden="true"
style={{ overflow: 'visible' }}
>
<path
d={`${TRAFFIC_LINE} L330 44 L0 44 Z`}
fill="rgba(179, 191, 255, 0.07)"
/>
<path
d={TRAFFIC_LINE}
stroke="`#b3bfff`"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<circle cx="330" cy="5" r="3.5" fill="`#b3bfff`" />
</svg>
</div>
🤖 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 `@docs/src/app/og/`[...slug]/generate.tsx around lines 182 - 202, Update the
SVG dimensions in the chart markup around the TRAFFIC_LINE paths and endpoint
circle so the circle at cx="330" with radius 3.5 is fully contained within the
viewBox and rendered width; preserve the existing chart geometry and styling
while adding sufficient right-side space to prevent clipping.

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.

1 participant