Skip to content

Commit 8982cab

Browse files
committed
fix: allow missing vue-router
1 parent c9389d0 commit 8982cab

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/runtime/composables/defineOgImage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,20 @@ export function defineOgImageScreenshot() {
2222
export function defineOgImage(options: OgImagePayload = {}) {
2323
if (process.server) {
2424
const router = useRouter()
25+
const route = router?.currentRoute?.value?.path || ''
2526
useServerHead({
2627
meta: [
2728
{
2829
property: 'og:image',
29-
content: () => options.runtime ? `${router.currentRoute.value.path}/${RuntimeImageSuffix}` : MetaOgImageContentPlaceholder,
30+
content: () => options.runtime ? `${route}/${RuntimeImageSuffix}` : MetaOgImageContentPlaceholder,
3031
},
3132
],
3233
link: options.component
3334
? [
3435
{
3536
id: LinkPrerenderId,
3637
rel: 'prerender',
37-
href: `${router.currentRoute.value.path}/${HtmlRendererRoute}`,
38+
href: `${route}/${HtmlRendererRoute}`,
3839
},
3940
]
4041
: [],

0 commit comments

Comments
 (0)