Skip to content

add changelog template for dynamic OG images#1776

Merged
ComputelessComputer merged 1 commit intomainfrom
jj-branch-15
Nov 21, 2025
Merged

add changelog template for dynamic OG images#1776
ComputelessComputer merged 1 commit intomainfrom
jj-branch-15

Conversation

@ComputelessComputer
Copy link
Collaborator

No description provided.

@netlify
Copy link

netlify bot commented Nov 21, 2025

Deploy Preview for hyprnote ready!

Name Link
🔨 Latest commit 68b4ce8
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/69206e8c9fc4e600088c9141
😎 Deploy Preview https://deploy-preview-1776--hyprnote.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

📝 Walkthrough

Walkthrough

Adds changelog variant support to OG image generation with schema validation. Introduces conditional rendering between template and changelog types, dynamic font loading, and development-mode guards to prevent OG generation in dev environments (localhost, 127.0.0.1, or CONTEXT=dev). Updates edge function config with conditional excludedPath.

Changes

Cohort / File(s) Change Summary
OG Image Changelog Support
apps/web/netlify/edge-functions/og.tsx
Introduces changelog OG variant with discriminated union schema (changelogSchema and templateSchema), adds renderChangelogTemplate function for changelog-styled rendering, implements dev-mode guards (localhost/127.0.0.1/CONTEXT=dev), adds dynamic font loading for changelog renders, and updates config to conditionally exclude /og path in dev.

Sequence Diagram

sequenceDiagram
    participant Client
    participant EdgeFunc as Edge Function
    participant Validator as Schema Validator
    participant Renderer as Renderer
    participant Response

    Client->>EdgeFunc: GET /og?type=changelog&version=v1.0
    
    Note over EdgeFunc: Dev mode guard<br/>(localhost check)
    
    alt In Development
        EdgeFunc->>Response: 404 (dev guard)
    else In Production
        EdgeFunc->>Validator: Parse & validate params
        
        alt Valid changelog params
            Validator->>EdgeFunc: ✓ version, isNightly
            EdgeFunc->>Renderer: renderChangelogTemplate(params)<br/>+ fonts
            Renderer->>Response: OG Image Response
        else Valid template params
            Validator->>EdgeFunc: ✓ template data
            EdgeFunc->>Renderer: renderTemplate(params)
            Renderer->>Response: OG Image Response
        else Invalid params
            Validator->>Response: Error Response
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Schema design: Validate discriminated union approach for OGSchema with both templateSchema and changelogSchema
  • Rendering logic: Review renderChangelogTemplate function, especially conditional background, header, version display, and image composition
  • Dev-mode guards: Ensure localhost/127.0.0.1/CONTEXT checks prevent unintended OG generation
  • Font loading: Verify dynamic font loading and passing to ImageResponse doesn't introduce memory/performance issues
  • Config changes: Confirm excludedPath logic correctly applies in dev environments

Possibly related PRs

  • OG image with netlify function #1700: Main PR extending the same Netlify edge function with changelog handling, schema parsing, render template functions, and development-mode guards for OG image generation.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a changelog template for OG images as detailed in the raw summary.
Description check ✅ Passed No description was provided by the author; this is a minimal but valid pull request without descriptive text.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jj-branch-15

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
apps/web/netlify/edge-functions/og.tsx (4)

14-21: OG schema + parsing look solid; a couple of tiny schema nits

The discriminated union and parseSearchParams branching behave correctly and fail fast on invalid combinations. Two minor cleanups you could consider:

  • isNightly is always constructed as a boolean (=== "true"), so z.boolean().optional().default(false) never actually applies the default. You could simplify to z.boolean() or let Zod handle the default by omitting the explicit boolean in the input.
  • If version is expected to be non‑empty / follow a version pattern, tightening version: z.string() to something like z.string().min(1) (or a regex) would give earlier, clearer validation failures.

These are non‑blocking and more about tightening intent than functionality.

Also applies to: 28-40


105-215: Changelog template layout is clear; check the screenshot height vs canvas

The overall JSX and styling for the changelog OG look good and match typical 1200×630 dimensions. One layout detail to double‑check:

  • Root container height is 630px, but the image section is positioned at top: 157px with height: 707px. That means the bottom ~234px of the screenshot will always be clipped by the canvas. If you intended the full screenshot to be visible, consider aligning these heights (e.g., reducing the image section height) or adjusting the top offset.

Optionally, you could also add an alt attribute on the <img> for better tooling support, even though this is only used for OG rendering.


220-225: Dev guards and Deno.env usage are reasonable; ensure they match your build/runtime setup

The hostname/CONTEXT === "dev" guard plus config.excludedPath is a nice belt‑and‑suspenders approach to avoiding OG generation in dev.

One thing to keep in mind:

  • Deno.env.get("CONTEXT") is used both at runtime and at module initialization in config. If this file is ever type‑checked or imported in a non‑Deno/Netlify context (e.g., Node‑based tooling that doesn’t provide Deno types/globals), the new Deno references can cause type or runtime issues unless the file is excluded from that toolchain or Deno is declared in types.

If your TS/build config already treats this as Deno‑only code, you’re fine; otherwise, you may want to explicitly exclude it or gate env access.

Also applies to: 285-285


243-271: Handler branching and font loading work, but you may want to cache fonts

The type‑based branching between renderChangelogTemplate and renderTemplate is straightforward and keeps JSX concerns isolated. The per‑request font loading for the changelog variant will work, but it has some overhead:

  • Each changelog request refetches both font files and converts them to ArrayBuffers, even though the font assets are static.
  • Since ImageResponse accepts a static fonts array, you could move the font fetching to module scope (or cache promises in module‑level variables) and reuse the loaded fonts across requests to cut latency and external calls.

For example, a cached approach could be:

// at module scope
const loraFontPromise = fetch("...Lora.ttf").then(r => r.arrayBuffer());
const ibmPlexMonoFontPromise = fetch("...IBM.ttf").then(r => r.arrayBuffer());

// in handler, when params.type === "changelog"
const [loraFont, ibmPlexMonoFont] = await Promise.all([
  loraFontPromise,
  ibmPlexMonoFontPromise,
]);
const fonts = [
  { name: "Lora", data: loraFont, weight: 700, style: "normal" },
  { name: "IBM Plex Mono", data: ibmPlexMonoFont, weight: 400, style: "normal" },
];

Not required, but it will make repeated OG generation cheaper.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b92bf79 and 68b4ce8.

📒 Files selected for processing (1)
  • apps/web/netlify/edge-functions/og.tsx (4 hunks)
⏰ 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). (4)
  • GitHub Check: Redirect rules - hyprnote
  • GitHub Check: Header rules - hyprnote
  • GitHub Check: Pages changed - hyprnote
  • GitHub Check: fmt

@ComputelessComputer ComputelessComputer merged commit d30649c into main Nov 21, 2025
11 checks passed
@ComputelessComputer ComputelessComputer deleted the jj-branch-15 branch November 21, 2025 14:00
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