@@ -16,7 +16,7 @@ import richTextSerializer from '#build/prismic/proxy/richTextSerializer'
1616export default defineNuxtPlugin ( {
1717 name : 'prismic:setup' ,
1818 parallel : true ,
19- async setup ( nuxtApp ) {
19+ async setup ( nuxtApp ) {
2020 const options : PrismicModuleOptions = useRuntimeConfig ( ) . public . prismic
2121 let client : Client | undefined
2222 if ( typeof _client === 'function' ) {
@@ -25,7 +25,7 @@ export default defineNuxtPlugin({
2525 }
2626 catch ( error ) {
2727 console . error ( '[@nuxtjs/prismic] An error happened while resolving your Prismic custom client, disabling Prismic module gracefully...' , error )
28-
28+
2929 // The Vue plugin still requires a client to work, we're providing an obviously broken one.
3030 client = createClient (
3131 'error-resolving-custom-client' ,
@@ -36,9 +36,9 @@ export default defineNuxtPlugin({
3636 else {
3737 client = _client
3838 }
39-
39+
4040 const endpoint = options . environment || options . endpoint || client ?. documentAPIEndpoint || ''
41-
41+
4242 const prismicPlugin = createPrismic ( {
4343 ...options ,
4444 endpoint,
@@ -53,24 +53,24 @@ export default defineNuxtPlugin({
5353 ...options . components ,
5454 } ,
5555 } )
56-
56+
5757 nuxtApp . vueApp . use ( prismicPlugin )
58-
58+
5959 if ( options . preview ) {
6060 const previewCookie = useCookie ( 'io.prismic.preview' ) . value
61-
61+
6262 // Update client with req when running server side
6363 if ( import . meta. server ) {
6464 const req = useRequestEvent ( ) ?. node . req
6565 if ( req ) {
6666 prismicPlugin . client . enableAutoPreviewsFromReq ( req )
6767 }
6868 }
69-
69+
7070 if ( previewCookie ) {
7171 try {
7272 const session = typeof previewCookie === 'string' ? JSON . parse ( decodeURIComponent ( previewCookie ) ) : previewCookie
73-
73+
7474 if ( Object . keys ( session ) . some ( key =>
7575 key in session
7676 && typeof session [ key ] === 'object'
@@ -95,7 +95,7 @@ export default defineNuxtPlugin({
9595 }
9696 }
9797 }
98-
98+
9999 if ( options . toolbar && prismicPlugin . client ?. repositoryName ) {
100100 // Add toolbar
101101 useHead ( {
@@ -112,9 +112,9 @@ export default defineNuxtPlugin({
112112 // TODO: We might want to let user disable this behavior because it might have unexpected side effects
113113 useCookie ( 'io.prismic.preview' ) . value = null
114114 }
115-
115+
116116 return {
117117 provide : { prismic : prismicPlugin } ,
118118 }
119- }
119+ } ,
120120} )
0 commit comments