🎉 Initial Commit
This commit is contained in:
		
							
								
								
									
										31
									
								
								application/plugins/naive-ui.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								application/plugins/naive-ui.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | ||||
| import { setup } from '@css-render/vue3-ssr' | ||||
| import { defineNuxtPlugin } from '#app' | ||||
|  | ||||
| export default defineNuxtPlugin((nuxtApp) => { | ||||
|   if (process.server) { | ||||
|     const { collect } = setup(nuxtApp.vueApp) | ||||
|     const originalRenderMeta = nuxtApp.ssrContext?.renderMeta | ||||
|     nuxtApp.ssrContext = nuxtApp.ssrContext || {} | ||||
|     nuxtApp.ssrContext.renderMeta = () => { | ||||
|       if (!originalRenderMeta) { | ||||
|         return { | ||||
|           headTags: collect() | ||||
|         } | ||||
|       } | ||||
|       const originalMeta = originalRenderMeta() | ||||
|       if ('then' in originalMeta) { | ||||
|         return originalMeta.then((resolvedOriginalMeta) => { | ||||
|           return { | ||||
|             ...resolvedOriginalMeta, | ||||
|             headTags: resolvedOriginalMeta['headTags'] + collect() | ||||
|           } | ||||
|         }) | ||||
|       } else { | ||||
|         return { | ||||
|           ...originalMeta, | ||||
|           headTags: originalMeta['headTags'] + collect() | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| }) | ||||
		Reference in New Issue
	
	Block a user