Skip to content

Commit 71162ca

Browse files
committed
feat(vitepress, vitesse): support legacy user config
1 parent a972d1b commit 71162ca

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

packages/vite/src/vitepress.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { createSchemaOrg } from '@vueuse/schema-org'
1+
import { createSchemaOrg, resolveUserConfig } from '@vueuse/schema-org'
22
import type { EnhanceAppContext } from 'vitepress'
33
import { createHead } from '@vueuse/head'
44
import { watch } from 'vue'
5-
import type { MetaInput } from './'
5+
import type { UserConfig } from '@vueuse/schema-org'
6+
7+
export function installSchemaOrg(ctx: EnhanceAppContext, config: UserConfig) {
8+
const resolvedConfig = resolveUserConfig(config)
69

7-
export function installSchemaOrg(ctx: EnhanceAppContext, meta: MetaInput) {
810
// check if `createHead` has already been done
911
let head = ctx.app._context.provides.usehead
1012
if (!head) {
@@ -19,7 +21,7 @@ export function installSchemaOrg(ctx: EnhanceAppContext, meta: MetaInput) {
1921
...ctx.siteData.value,
2022
...ctx.router.route.data,
2123
...ctx.router.route.data.frontmatter,
22-
...meta,
24+
...resolvedConfig.meta,
2325
}
2426
},
2527
updateHead(fn) {

packages/vite/src/vitesse.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { createSchemaOrg } from '@vueuse/schema-org'
1+
import { createSchemaOrg, resolveUserConfig } from '@vueuse/schema-org'
22
import type { ViteSSGContext } from 'vite-ssg'
3-
import type { MetaInput } from './'
3+
import type { UserConfig } from '@vueuse/schema-org'
44

5-
export function installSchemaOrg(ctx: ViteSSGContext, meta: MetaInput) {
5+
export function installSchemaOrg(ctx: ViteSSGContext, config: UserConfig) {
66
const ssr = !ctx.isClient
77

8+
const resolvedConfig = resolveUserConfig(config)
9+
810
const client = createSchemaOrg({
911
updateHead(fn) {
1012
ctx.head?.addHeadObjs(fn)
@@ -23,7 +25,7 @@ export function installSchemaOrg(ctx: ViteSSGContext, meta: MetaInput) {
2325

2426
return {
2527
path: ctx.router.currentRoute.value.path,
26-
...meta ?? {},
28+
...resolvedConfig.meta,
2729
...ctx.router.currentRoute.value.meta,
2830
}
2931
},

0 commit comments

Comments
 (0)