Skip to content

Commit 8904f8f

Browse files
committed
fix: broken getOgImagePath usage
1 parent 5f52b55 commit 8904f8f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/runtime/app/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import type { Head } from '@unhead/vue'
22
import type { NuxtSSRContext } from 'nuxt/app'
33
import type { OgImageOptions, OgImagePrebuilt, OgImageRuntimeConfig } from '../types'
4-
import { useHead, useRuntimeConfig } from '#app'
54
import { componentNames } from '#build/nuxt-og-image/components.mjs'
65
import { resolveUnrefHeadInput } from '@unhead/vue'
76
import { defu } from 'defu'
87
import { stringify } from 'devalue'
8+
import { useHead, useRuntimeConfig } from 'nuxt/app'
99
import { joinURL, withQuery } from 'ufo'
1010
import { generateMeta, separateProps } from '../shared'
1111

@@ -85,7 +85,7 @@ export function resolveComponentName(component: OgImageOptions['component'], fal
8585

8686
export function getOgImagePath(pagePath: string, _options?: Partial<OgImageOptions>) {
8787
const baseURL = useRuntimeConfig().app.baseURL
88-
const extension = _options?.extension || useOgImageRuntimeConfig().defaults.extension
88+
const extension = _options?.extension || useOgImageRuntimeConfig().defaults?.extension || 'png'
8989
const path = joinURL('/', baseURL, `__og-image__/${import.meta.prerender ? 'static' : 'image'}`, pagePath, `og.${extension}`)
9090
if (Object.keys(_options?._query || {}).length) {
9191
return withQuery(path, _options!._query!)
@@ -96,6 +96,7 @@ export function getOgImagePath(pagePath: string, _options?: Partial<OgImageOptio
9696
export function useOgImageRuntimeConfig() {
9797
const c = useRuntimeConfig()
9898
return {
99+
defaults: {},
99100
...(c['nuxt-og-image'] as Record<string, any>),
100101
app: {
101102
baseURL: c.app.baseURL,

0 commit comments

Comments
 (0)