Skip to content

Commit 87d869e

Browse files
committed
chore: type issues
1 parent 81e906b commit 87d869e

File tree

5 files changed

+5
-14
lines changed

5 files changed

+5
-14
lines changed

src/content.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Collection } from '@nuxt/content'
2-
import type { TypeOf, ZodRawShape } from 'zod'
32
import { z } from '@nuxt/content'
43

54
export const ogImageSchema = z.object({
@@ -12,16 +11,10 @@ export const schema = z.object({
1211
ogImage: ogImageSchema,
1312
})
1413

15-
export type OgImageSchema = TypeOf<typeof schema>
16-
17-
type ExtendedSchema<T extends ZodRawShape> = T & {
18-
ogImage: typeof ogImageSchema
19-
}
20-
21-
export function asOgImageCollection<T extends ZodRawShape>(collection: Collection<T>): Collection<ExtendedSchema<T>> {
14+
export function asOgImageCollection<T>(collection: Collection<T>): Collection<T> {
2215
if (collection.type === 'page') {
2316
// @ts-expect-error untyped
2417
collection.schema = collection.schema ? schema.extend(collection.schema.shape) : schema
2518
}
26-
return collection as Collection<ExtendedSchema<T>>
19+
return collection
2720
}

src/runtime/app/utils/plugins.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export function ogImageCanonicalUrls(nuxtApp: NuxtSSRContext['nuxt']) {
2323
if (isInternalRoute(path))
2424
return
2525

26-
// @ts-expect-error untyped
2726
ssrContext?.head.use(TemplateParamsPlugin)
2827
// unhead plugin to correct missing site URL, this is to fix the Nuxt Content integration not being able to resolve the correct URL
2928
ssrContext?.head.use({

src/runtime/server/util/cache.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { prefixStorage } from 'unstorage'
1010
export async function useOgImageBufferCache(ctx: OgImageRenderEventContext, options: {
1111
baseCacheKey: string | false
1212
cacheMaxAgeSeconds?: number
13-
}): Promise<void | H3Error | { cachedItem: false | BufferSource, enabled: boolean, update: (image: BufferSource) => Promise<void> }> {
13+
}): Promise<void | H3Error | { cachedItem: false | BufferSource, enabled: boolean, update: (image: BufferSource | Buffer | Uint8Array) => Promise<void> }> {
1414
const maxAge = Number(options.cacheMaxAgeSeconds)
1515
let enabled = !import.meta.dev && import.meta.env?.MODE !== 'test' && maxAge > 0
1616
const cache = prefixStorage(useStorage(), withTrailingSlash(options.baseCacheKey || '/'))
@@ -81,7 +81,6 @@ export async function useOgImageBufferCache(ctx: OgImageRenderEventContext, opti
8181
'cache-control': `public, s-maxage=${maxAge}, stale-while-revalidate`,
8282
}
8383
setHeaders(ctx.e, headers)
84-
// @ts-expect-error untyped
8584
await cache.setItem(key, {
8685
value,
8786
headers,

src/runtime/server/util/eventHandlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export async function imageEventHandler(e: H3Event) {
173173
if (cacheApi instanceof H3Error)
174174
return cacheApi
175175

176-
let image: H3Error | BufferSource | false | void = cacheApi.cachedItem
176+
let image: H3Error | BufferSource | Buffer | Uint8Array | false | void = cacheApi.cachedItem
177177
if (!image) {
178178
image = await renderer.createImage(ctx)
179179
if (image instanceof H3Error)

src/runtime/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export type RendererOptions = Omit<OgImageOptions, 'extension'> & { extension: O
179179
export interface Renderer {
180180
name: 'chromium' | 'satori'
181181
supportedFormats: Partial<RendererOptions['extension']>[]
182-
createImage: (e: OgImageRenderEventContext) => Promise<H3Error | BufferSource | void>
182+
createImage: (e: OgImageRenderEventContext) => Promise<H3Error | BufferSource | Buffer | Uint8Array | void | undefined>
183183
debug: (e: OgImageRenderEventContext) => Promise<Record<string, any>>
184184
}
185185

0 commit comments

Comments
 (0)