mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-14 12:14:41 +01:00
docs(app): improve framework hydration (#2780)
Co-authored-by: Sébastien Chopin <seb@nuxt.com>
This commit is contained in:
35
docs/app/plugins/framework.ts
Normal file
35
docs/app/plugins/framework.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
export default defineNuxtPlugin({
|
||||
enforce: 'post',
|
||||
setup() {
|
||||
const { framework } = useSharedData()
|
||||
|
||||
if (import.meta.client) {
|
||||
useHead({
|
||||
htmlAttrs: {
|
||||
'data-framework': framework
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (import.meta.server) {
|
||||
useHead({
|
||||
script: [{
|
||||
innerHTML: `
|
||||
function getCookie(name) {
|
||||
var value = '; ' + window.document.cookie;
|
||||
var parts = value.split('; ' + name + '=');
|
||||
if (parts.length === 2) {
|
||||
return parts.pop()?.split(';').shift();
|
||||
}
|
||||
}
|
||||
|
||||
var framework = getCookie('nuxt-ui-framework');
|
||||
document.documentElement.setAttribute('data-framework', framework || 'nuxt');
|
||||
`.replace(/\s+/g, ' '),
|
||||
type: 'text/javascript',
|
||||
tagPriority: -1
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user