Skip to content

Commit

Permalink
fix: allow missing vue-router
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Dec 15, 2022
1 parent c9389d0 commit 8982cab
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/runtime/composables/defineOgImage.ts
Expand Up @@ -22,19 +22,20 @@ export function defineOgImageScreenshot() {
export function defineOgImage(options: OgImagePayload = {}) {
if (process.server) {
const router = useRouter()
const route = router?.currentRoute?.value?.path || ''
useServerHead({
meta: [
{
property: 'og:image',
content: () => options.runtime ? `${router.currentRoute.value.path}/${RuntimeImageSuffix}` : MetaOgImageContentPlaceholder,
content: () => options.runtime ? `${route}/${RuntimeImageSuffix}` : MetaOgImageContentPlaceholder,
},
],
link: options.component
? [
{
id: LinkPrerenderId,
rel: 'prerender',
href: `${router.currentRoute.value.path}/${HtmlRendererRoute}`,
href: `${route}/${HtmlRendererRoute}`,
},
]
: [],
Expand Down

0 comments on commit 8982cab

Please sign in to comment.