diff --git a/packages/vite/src/vitepress.ts b/packages/vite/src/vitepress.ts index 978a408..035fa4c 100644 --- a/packages/vite/src/vitepress.ts +++ b/packages/vite/src/vitepress.ts @@ -1,10 +1,12 @@ -import { createSchemaOrg } from '@vueuse/schema-org' +import { createSchemaOrg, resolveUserConfig } from '@vueuse/schema-org' import type { EnhanceAppContext } from 'vitepress' import { createHead } from '@vueuse/head' import { watch } from 'vue' -import type { MetaInput } from './' +import type { UserConfig } from '@vueuse/schema-org' + +export function installSchemaOrg(ctx: EnhanceAppContext, config: UserConfig) { + const resolvedConfig = resolveUserConfig(config) -export function installSchemaOrg(ctx: EnhanceAppContext, meta: MetaInput) { // check if `createHead` has already been done let head = ctx.app._context.provides.usehead if (!head) { @@ -19,7 +21,7 @@ export function installSchemaOrg(ctx: EnhanceAppContext, meta: MetaInput) { ...ctx.siteData.value, ...ctx.router.route.data, ...ctx.router.route.data.frontmatter, - ...meta, + ...resolvedConfig.meta, } }, updateHead(fn) { diff --git a/packages/vite/src/vitesse.ts b/packages/vite/src/vitesse.ts index b6a42b7..5a00cf0 100644 --- a/packages/vite/src/vitesse.ts +++ b/packages/vite/src/vitesse.ts @@ -1,10 +1,12 @@ -import { createSchemaOrg } from '@vueuse/schema-org' +import { createSchemaOrg, resolveUserConfig } from '@vueuse/schema-org' import type { ViteSSGContext } from 'vite-ssg' -import type { MetaInput } from './' +import type { UserConfig } from '@vueuse/schema-org' -export function installSchemaOrg(ctx: ViteSSGContext, meta: MetaInput) { +export function installSchemaOrg(ctx: ViteSSGContext, config: UserConfig) { const ssr = !ctx.isClient + const resolvedConfig = resolveUserConfig(config) + const client = createSchemaOrg({ updateHead(fn) { ctx.head?.addHeadObjs(fn) @@ -23,7 +25,7 @@ export function installSchemaOrg(ctx: ViteSSGContext, meta: MetaInput) { return { path: ctx.router.currentRoute.value.path, - ...meta ?? {}, + ...resolvedConfig.meta, ...ctx.router.currentRoute.value.meta, } },