feat: add OG image for compare pages#2277
feat: add OG image for compare pages#2277Adebesin-Cell wants to merge 16 commits intonpmx-dev:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a server-rendered OG-image Vue SFC at Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8bf4f3f9-b99e-4b4a-82b3-eb8cf42d26e8
📒 Files selected for processing (2)
app/components/OgImage/Compare.vueapp/pages/compare.vue
Fetches real weekly downloads and latest version for each package, renders a horizontal bar chart with gradient bars sized relative to the highest-downloaded package. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Show descriptive text when no packages are selected, matching the Default template's badge style. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pass i18n-translated empty description from the page as a prop since OG image components don't have access to $t. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
app/components/OgImage/Compare.vue (2)
41-69: Top-level await reads computed value during setup.The code accesses
displayPackages.valueat the top level of<script setup>, which evaluates during component setup. While this works in Nuxt OG image server-rendering contexts where props are available immediately, this pattern can be fragile if the component is ever used in a different context.Consider using
onMountedor Nuxt's data-fetching composables if issues arise, but for a server-only OG image component, the current approach should work correctly.
138-138: Consider potential duplicate key collision.Using
:key="pkg.name"assumes package names are unique. If the same package name appears multiple times in the input (e.g.,?packages=react,react), this would cause a key collision warning and potentially incorrect rendering.For an OG image component, this edge case is unlikely to matter, but you could use the index as a fallback:
💡 Optional fix
- <div v-for="pkg in stats" :key="pkg.name" class="flex flex-col gap-1"> + <div v-for="(pkg, index) in stats" :key="`${pkg.name}-${index}`" class="flex flex-col gap-1">
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 89a5a390-89bf-49d9-b45a-2cf8521a47c3
📒 Files selected for processing (3)
app/components/OgImage/Compare.vueapp/pages/compare.vuetest/unit/a11y-component-coverage.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- app/pages/compare.vue
|
Great work on the new compare OG image! Perhaps we could give the metrics (weekly downloads) a bit more visual prominence? I personally think the download numbers are the most important info here — the progress bars already do a great job showing the relative scale, but the absolute numbers are what people scan for first. |
… image Bump download metrics from text-xl/gray to text-2xl/font-medium/lighter color so absolute numbers are easier to scan at a glance.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/components/OgImage/Compare.vue (1)
22-29: Normalisestring[]input the same as comma-separated input.Line 28 passes array input through as-is, so whitespace-only or empty entries can leak into fetch calls. Normalising both paths keeps behaviour consistent.
♻️ Suggested refactor
const displayPackages = computed(() => { const raw = props.packages - const list = - typeof raw === 'string' - ? raw - .split(',') - .map(p => p.trim()) - .filter(Boolean) - : raw + const list = (typeof raw === 'string' ? raw.split(',') : raw) + .map(p => p.trim()) + .filter(Boolean) return list.slice(0, 4) })
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f198a43d-d3b0-4229-9a86-9da70bcb40d8
📒 Files selected for processing (1)
app/components/OgImage/Compare.vue
|
Amazing 🤩 Is there a limit for how many packages can be compared at once or could this be abused to generate OG images that overflow the image dimensions? |
There is currently a limit of 4 on the compare page, but we'd like to either increase the limit or remove it entirely eventually. We discussed about this on discord, and @Adebesin-Cell has a plan for various scenarios to avoid overflows with different presentations (to be implemented when it becomes necessary). |
Thanks for the quick answer and ping. This looks perfect to me then 👍 |
- Add 2.5s timeout to npm API requests to prevent OG image render stalls - Increase download numbers to text-3xl font-bold white for better visual prominence on the compare OG card Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c7891906-da84-49e2-9b77-01d59b8f9535
📒 Files selected for processing (1)
app/components/OgImage/Compare.vue
- Apply trim/filter to string[] input, not just comma-separated strings - Return 0% width for zero-download entries instead of a misleading 5% - Cap bar width at 100% Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (2)
app/components/OgImage/Compare.vue (2)
137-137: Consider using a composite key to handle potential duplicate package names.If duplicate package names are passed via URL parameters (e.g.,
?packages=express,express),pkg.namewon't be unique, which could cause Vue rendering issues. While the upstream page may prevent this in the UI, the OG image endpoint could receive arbitrary query parameters.🔧 Suggested fix using index-based composite key
- <div v-for="pkg in stats" :key="pkg.name" class="flex flex-col gap-1"> + <div v-for="(pkg, index) in stats" :key="`${pkg.name}-${index}`" class="flex flex-col gap-1">
95-98: Conflicting styles: inlinebackgroundColoroverrides the gradient class.The element has
bg-gradient-to-tr from-[#3b82f6]in the class, but the inline:style="{ backgroundColor: primaryColor }"completely overrides the gradient, making the gradient class dead code.If a gradient is intended, consider using CSS custom properties or removing the gradient class. If a solid colour is intended, the gradient class can be removed.
🧹 Option A: Remove unused gradient class (if solid colour is intended)
<div - class="flex items-center justify-center w-14 h-14 p-3 rounded-xl shadow-lg bg-gradient-to-tr from-[`#3b82f6`]" + class="flex items-center justify-center w-14 h-14 p-3 rounded-xl shadow-lg" :style="{ backgroundColor: primaryColor }" >🎨 Option B: Use gradient with dynamic colour (if gradient is intended)
<div - class="flex items-center justify-center w-14 h-14 p-3 rounded-xl shadow-lg bg-gradient-to-tr from-[`#3b82f6`]" - :style="{ backgroundColor: primaryColor }" + class="flex items-center justify-center w-14 h-14 p-3 rounded-xl shadow-lg" + :style="{ background: `linear-gradient(to top right, ${primaryColor}, ${primaryColor}80)` }" >
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bd50c762-941d-4b3d-9349-374cd8fd4060
📒 Files selected for processing (1)
app/components/OgImage/Compare.vue
Do you have ellipsis on long pack names, so it fits with 999.9M/wk ? |
Add max-width and ellipsis truncation to package names so they don't overflow when paired with large download numbers and version badges. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Good catch! fixed eac610a |

Better social preview for compare pages.
2 Pkgs

4 Pkgs
