Skip to content

Fix broken OG image URL generation in contentlayer.config.ts #9

@seanoliver

Description

@seanoliver

Issue

The OG image URL generation in contentlayer.config.ts has invalid JavaScript syntax that will cause runtime errors.

Location: contentlayer.config.ts:48-50

Current Code (Broken)

image: {
  type: 'string',
  resolve: (doc) =>
    `https://seanoliver.dev/api/og?title=${
      (doc.title.split(' '), join('+'))
    }`,
},

Problem

The syntax (doc.title.split(' '), join('+')) uses the comma operator incorrectly:

  1. doc.title.split(' ') creates an array but the result is discarded
  2. The comma operator evaluates both expressions but only returns the second
  3. join('+') is called without context (not on the array), causing a ReferenceError

This would fail with: ReferenceError: join is not defined

Expected Fix

Should use method chaining:

image: {
  type: 'string',
  resolve: (doc) =>
    `https://seanoliver.dev/api/og?title=${doc.title.split(' ').join('+')}`,
},

Context

Discovered during RSS feed PR (#7) code review, but intentionally left out of scope to maintain PR focus on RSS functionality only.

Labels

  • bug
  • contentlayer
  • og-images

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions