Skip to content

Commit

Permalink
fix(vitesse): register DOM and route reactivity
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Aug 16, 2022
1 parent 5a6349e commit e7ac3b3
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/vite/src/vitesse.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createSchemaOrg } from '@vueuse/schema-org'
import type { ViteSSGContext } from 'vite-ssg'
import { watch } from 'vue-demi'
import type { MetaInput } from './'

export function installSchemaOrg(ctx: ViteSSGContext, meta: MetaInput) {
Expand All @@ -9,8 +8,7 @@ export function installSchemaOrg(ctx: ViteSSGContext, meta: MetaInput) {
const client = createSchemaOrg({
updateHead(fn) {
ctx.head?.addHeadObjs(fn)
if (!ssr)
ctx.head?.updateDOM()
ctx.head?.updateDOM()
},
meta() {
const inferredMeta: Record<string, any> = {}
Expand Down Expand Up @@ -38,10 +36,9 @@ export function installSchemaOrg(ctx: ViteSSGContext, meta: MetaInput) {
return
}

watch(() => ctx.router.currentRoute.value, () => {
ctx.router.afterEach(() => {
client.generateSchema()
client.setupDOM()
})
client.setupDOM()

return client
}

0 comments on commit e7ac3b3

Please sign in to comment.