Skip to content

Commit

Permalink
Remove contentType option in favor of type option
Browse files Browse the repository at this point in the history
  • Loading branch information
neg4n committed Apr 6, 2022
1 parent ad8fd18 commit 9b825f3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export type NextApiOgImageConfig<
'html' | 'react'
>
strategy?: StrategyOption
contentType?: string
cacheControl?: string
width?: number
height?: number
Expand All @@ -59,7 +58,6 @@ export function withOGImage<
StrategyDetails extends string | object = string,
>(options: NextApiOgImageConfig<Strategy, StrategyDetails>) {
const defaultOptions: Except<NextApiOgImageConfig<Strategy, StrategyDetails>, 'template'> = {
contentType: options.type ? `image/${options.type}` : 'image/png',
strategy: 'query',
cacheControl: 'max-age 3600, must-revalidate',
width: 1200,
Expand All @@ -78,10 +76,9 @@ export function withOGImage<
template: { html: htmlTemplate, react: reactTemplate },
cacheControl,
strategy,
contentType,
type,
width,
height,
type,
quality,
dev: { inspectHtml, errorsInResponse },
} = options
Expand Down Expand Up @@ -117,7 +114,7 @@ export function withOGImage<

response.setHeader(
'Content-Type',
!isProductionLikeMode(envMode) && inspectHtml ? 'text/html' : contentType,
!isProductionLikeMode(envMode) && inspectHtml ? 'text/html' : type ? `image/${type}` : 'image/png',
)
response.setHeader('Cache-Control', cacheControl)

Expand Down

0 comments on commit 9b825f3

Please sign in to comment.