feat(og): add support for shortcuts og images#2106
Conversation
✅ Deploy Preview for hyprnote-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for hyprnote ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
📝 WalkthroughWalkthroughThis PR extends the OG image generation system to support a new "shortcuts" content type with a dedicated schema and rendering template. Existing template rendering is refactored to use a shared generic renderer, and gallery pages now derive the correct ogType (templates or shortcuts) for accurate image generation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/web/src/routes/_view/gallery/$type.$slug.tsx (1)
43-44: DynamicogTypemapping is correct; consider reusing existing singular→plural mappingMapping
"template" | "shortcut"to"templates" | "shortcuts"here aligns with the OG edge handler’s expectedtypevalues and the new shortcuts schema, and the use ofencodeURIComponenton all text fields is appropriate.If you want to reduce duplication, you could optionally derive
ogTypefrom a shared helper (or reuse thecontentDirlogic used inRightSidebar) so singular/plural mappings stay in sync across the file when new gallery types are added.apps/web/netlify/edge-functions/og.tsx (1)
239-255: Generic OG template renderer refactor is clean and behavior‑preservingThe new
renderGenericTemplateplusrenderDocsTemplate/renderTemplatesTemplatewrappers nicely deduplicate the common layout while preserving the existing docs/templates behavior (header text, category source, title, optional description).If you want a tiny follow‑up cleanup,
needsCustomFontscould be simplified to something likeparams.type !== "meeting"now that all other branches use this generic layout or other custom‑font templates, but this is purely optional.Also applies to: 257-273
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/web/netlify/edge-functions/og.tsx(5 hunks)apps/web/src/routes/_view/gallery/$type.$slug.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Avoid creating a bunch of types/interfaces if they are not shared. Especially for function props, just inline them instead.
Never do manual state management for form/mutation. Use useForm (from tanstack-form) and useQuery/useMutation (from tanstack-query) instead for 99% of cases. Avoid patterns like setError.
If there are many classNames with conditional logic, usecn(import from@hypr/utils). It is similar toclsx. Always pass an array and split by logical grouping.
Usemotion/reactinstead offramer-motion.
Files:
apps/web/src/routes/_view/gallery/$type.$slug.tsxapps/web/netlify/edge-functions/og.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Redirect rules - hyprnote
- GitHub Check: Header rules - hyprnote
- GitHub Check: Pages changed - hyprnote
- GitHub Check: ci
- GitHub Check: fmt
🔇 Additional comments (1)
apps/web/netlify/edge-functions/og.tsx (1)
19-24: Shortcuts OG schema, parsing, rendering, and handler wiring look consistent
shortcutsSchemacorrectly mirrorstemplatesSchema(title, category, optional description) withtype: "shortcuts".OGSchemaincludes the shortcuts variant in the discriminated union, so TypeScript narrowing in the handler remains sound.parseSearchParams’stype === "shortcuts"branch reads the same fields as templates and validates them viaOGSchema.safeParse, giving the same failure mode (400) for invalid or missing params.renderShortcutsTemplateis a thin wrapper over the generic layout with a clear header label (Hyprnote / Shortcuts), which keeps styling aligned with templates/docs.- Handler dispatch and
needsCustomFontsboth now include"shortcuts", so shortcuts use the same font pipeline and rendering path as the other text-heavy types.No blocking issues here; this end‑to‑end wiring for shortcuts looks solid.
Also applies to: 46-46, 100-107, 275-282, 310-311, 316-316
No description provided.