fix: Fix OG image text overlap for long titles and descriptions#1303
Conversation
Truncate long OG title and description text before rendering to prevent overlap in the fumadocs 1200×630 template. Co-authored-by: Cursor <cursoragent@cursor.com>
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the PR adds title/description truncation helpers for the dynamic /api/og route to prevent text overlap in the fumadocs 1200×630 OG image template.
- Add
apps/www/lib/og-text.ts— introducesformatOgTitle(42-char limit),formatOgDescription(75-char limit), and a sharedtruncateOgTexthelper that normalizes whitespace and prefers word-boundary truncation. - Update
apps/www/app/api/og/route.tsx— applies the new formatters totitleanddescriptionbefore passing them togenerateOGImage. - Add unit and route tests — covers short strings, long title/description, word-boundary behavior, and the real metadata case that prompted the fix.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
## Summary Forward-ports two clean fixes from `dev` to `v1` using cherry-pick (not a bulk merge): - **OG text overflow fix** (#1303 / #1302) — cherry-picked `ba2111ab` - **Vitest project name collision** — exclude legacy `packages/cli` stub from root vitest projects ## Context `dev` and `v1` are intentionally diverged (see CONTRIBUTING Use Case 4). The recent reconciliation (#1292) only covered v0 feature parity (#1281, #1282) — it did not eliminate the ~48 file conflicts that appear when bulk-merging the branches. Those conflicts are expected due to structural differences (`packages/cli` → `packages/arkenv`, removed `/shared` exports, etc.). This PR uses the documented **forward-porting** workflow instead. ## Test plan - [x] `pnpm test run lib/og-text.test.ts app/api/og/route.test.tsx` passes (7/7) - [x] Root vitest starts without duplicate project name error Made with [Cursor](https://cursor.com) --------- Co-authored-by: Cursor <cursoragent@cursor.com>

Fixes #1302
Truncate long title and description strings in the
/api/ogroute before passing them togenerateOGImage, preventing text overlap in the fumadocs 1200×630 template. Short metadata is left unchanged.Test plan
formatOgTitle/formatOgDescription(short, long title, long description, word boundaries)using-other-validatorspage metadatapnpm run typecheck,pnpm run test,pnpm run fixpassMade with Cursor