@@ -3,7 +3,7 @@ import { defineNuxtPlugin } from '#app'
33import { unref , watch } from '#imports'
44import config from '#build/nuxt-schema-org-config.mjs'
55
6- export default defineNuxtPlugin ( ( nuxtApp ) => {
6+ export default defineNuxtPlugin ( async ( nuxtApp ) => {
77 const ssr = ! ! nuxtApp . ssrContext ?. url
88
99 const client = createSchemaOrg ( {
@@ -14,33 +14,33 @@ export default defineNuxtPlugin((nuxtApp) => {
1414 // computed so only need to be done once
1515 nuxtApp . _useHead ( unref ( fn ) )
1616 } ,
17- meta ( ) {
17+ async meta ( ) {
1818 const head = nuxtApp . vueApp . _context . provides . usehead
1919
2020 const inferredMeta : Record < string , any > = { }
2121 const headTag = head . headTags . reverse ( ) . filter ( t => t . tag === 'title' && ! ! t . props . children )
2222 if ( headTag . length )
2323 inferredMeta . title = headTag [ 0 ] . props . children
2424
25- return {
25+ const schemaOrgMeta = {
2626 path : nuxtApp . _route . path ,
2727 ...inferredMeta ,
2828 ...nuxtApp . _route . meta ,
2929 ...config . meta || { } ,
3030 }
31+ await nuxtApp . hooks . callHook ( 'schema-org:meta' , schemaOrgMeta )
32+ return schemaOrgMeta
3133 } ,
3234 } )
3335
3436 nuxtApp . vueApp . use ( client )
3537
3638 if ( ssr ) {
37- client . generateSchema ( )
38- client . setupDOM ( )
39+ await client . forceRefresh ( )
3940 return
4041 }
4142
4243 watch ( ( ) => nuxtApp . _route . path , ( ) => {
43- client . generateSchema ( )
44- client . setupDOM ( )
44+ client . forceRefresh ( )
4545 } )
4646} )
0 commit comments