Repository navigation
feat(web): add dynamic OpenGraph truth cards and social PNG download - #1868
Conversation
Implement /api/v1/rate/og and og-truth-card.tsx for product, 1v1 versus, and Deal Radar cards across vi/en/cs in 1200x630 and 1080x1350 formats, wire openGraph and twitter metadata, and add 1-click social PNG download to ProductShareAuditButton. Closes #1865
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 54 minutes. View limit details
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. |
|
PO acceptance: merge at 7755067 |
Summary
Implement Package 8A Feature F3 (approved by JOY on 2026-11-22 from
Docs/Proposals/2026-11-22-de-xuat-tinh-nang-moi-phase-8.html):/api/v1/rate/og+apps/web/src/lib/og-truth-card.tsx):#0f1113canvas,#161a1esurface,#FF2E29brand accent) PNG cards for 3 verified catalog entity types:product(verified floor price acrossX / 22retail chains, cross-store spread, Deal Radar badge, Bayesian buyer stars, Rate Lab score, 6-axis review trust signal, and fake-sale trap status),versus(head-to-head 2-device comparison with overall star scores, criterion wins, and floor prices), anddeals(Deal Radar summary across 22 retail chains).format=og(1200x630) andformat=social(1080x13504:5 portrait) acrossvi,en, andcswith full Vietnamese and Czech diacritics and zero external network calls (strictGeist-Regular.ttfcmapallowlist +\p{Cf}format stripping + NFC normalization).title,price, cache-busting params) and non-canonical enum/whitespace/control permutations (400), catalog-backed resolution viawithRateDataCache(404when unknown), eager PNG stream materialization insidetry/catch(500masked withCache-Control: no-store),BoundedSlidingWindowRateLimiter(60/min,429+Retry-After: 60), andCache-Control: public, s-maxage=3600, stale-while-revalidate=86400.openGraph.imagesandtwitter(summary_large_image,@rate_vn) ingenerateCategoryProductMetadata(coveringsmartphones,tablets,laptops,smartwatches,earbuds),/compare/[versus]/page.tsx, and/deals/page.tsx."Download truth card (PNG)"action insideProductShareAuditButton.tsx("productDetail"locale namespace acrossvi,en, andcs, including?v=variant selection parity).Review Gate
Security & DoS Reviewer,bcd532cc-fef2-44e3-8954-a65f8cc107fa): 0 P0, 4 P1, 1 P2, 0 P3 in Round 1 (exactGeist-Regular.ttfcmap+\p{Cf}filter blockingU+00ADoutbound font probes, eager PNG buffer materialization insidetry/catch, strict canonical enum query parsing +Object.prototypeslug blocklist,RATE_ITEM_MODELcanonical versus pair resolution, andItemModelUnavailableError-only catch). All 5 findings fixed and covered by unit tests.SEO, OG, Font & A11y Reviewer,dc4594fc-0b1a-400d-8f67-a092fe02c88b): 0 P0, 4 P1, 2 P2, 2 P3 in Round 1 (Geist-Regular.ttfcmapallowlist, canonical Item versus pairs,itemFromStatsmulti-variant Item floor price parity +?v=variant download resolution,/dealslimit: 50cache/KPI parity, undotted_product slug support, SatoriflexShrink: 0/flex: 1layout guards, English sentence case, andformatNumberreview count grouping). All findings fixed.Verification
pnpm --filter @repo/web test(including 18 offline PNG renders acrossproduct/versus/dealsxvi/en/csx1200x630/1080x1350verified withsharpmetadata, PNG magic bytes, and external-fetch interception)pnpm typecheckpnpm lintpnpm buildCloses #1865
Claimant: antigravity:0a1440be-c5c8-4ac0-8916-8f45aad1d36c
📌 TL;DR
This PR introduces a dynamic "Truth Card" Open Graph image generation system that renders server-side PNGs for product, comparison, and deals pages to enhance social sharing. It includes a new API route with strict security validation, rate limiting, and offline rendering capabilities, along with a new UI button for users to download these cards.
🎯 Type of Change
🔍 Changes Walkthrough
apps/web/locales/{cs,en,vi}.jsonapps/web/src/app/[locale]/compare/[versus]/page.tsxgenerateMetadatato usebuildOgTruthCardImagefor dynamic OG images and added Twitter card metadata.apps/web/src/app/[locale]/deals/page.tsxgenerateMetadatato usebuildOgTruthCardImagefor dynamic OG images and added Twitter card metadata.apps/web/src/app/[locale]/smartphones/[slug]/page.tsxbuildOgTruthCardImagefor dynamic OG images; addedslugprop toProductShareAuditButton.apps/web/src/app/api/v1/rate/og/route.tsGETrequests for OG truth cards. Includes rate limiting, strict query validation, and resolvers for product, versus, and deals data.apps/web/src/components/leaderboard/ProductShareAuditButton.tsxslugprop and a new "Download Truth Card" button that triggers a PNG download via the new API route.apps/web/src/lib/__tests__/product-detail-copy.test.tsapps/web/src/lib/__tests__/seo.test.tsapps/web/src/lib/og-truth-card.tsxnext/og(Satori). Includes data types, strict query parsing, text sanitization, and localized copy dictionaries.📊 Architectural Flow
sequenceDiagram participant User participant UI as ProductShareAuditButton participant API as /api/v1/rate/og participant Resolver as Data Resolvers participant Renderer as renderOgTruthCardPng User->>UI: Click "Download Truth Card" UI->>UI: resolveShareAuditOgDownloadUrl() UI->>API: GET /api/v1/rate/og?type=product&slug=...&download=1 API->>API: Rate Limit Check API->>API: parseOgTruthCardQuery (Strict Validation) API->>Resolver: resolveProduct(slug) Resolver-->>API: ProductTruthCardData API->>Renderer: renderOgTruthCardHttpResponse(data) Renderer->>Renderer: Satori/Next OG (Offline PNG Render) Renderer-->>API: PNG Buffer API-->>UI: 200 OK (image/png, Content-Disposition: attachment) UI->>User: Trigger Browser Download