mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-16 13:48:13 +00:00
fix(head): allow using the default slot for script content like noscript (#7858)
Co-authored-by: Martin Benndorf <martin.benndorf@gothaer.de>
This commit is contained in:
parent
e6ca07bdc0
commit
63c88056c7
@ -12,6 +12,7 @@
|
|||||||
<Title>Luck number: {{ dynamic }}</Title>
|
<Title>Luck number: {{ dynamic }}</Title>
|
||||||
<Meta name="description" :content="`My page's ${dynamic} description`" />
|
<Meta name="description" :content="`My page's ${dynamic} description`" />
|
||||||
<Link rel="preload" href="/test.txt" as="script" />
|
<Link rel="preload" href="/test.txt" as="script" />
|
||||||
|
<Script>console.log("hello script");</Script>
|
||||||
</Head>
|
</Head>
|
||||||
</Html>
|
</Html>
|
||||||
|
|
||||||
|
@ -90,9 +90,19 @@ export const Script = defineComponent({
|
|||||||
/** @deprecated **/
|
/** @deprecated **/
|
||||||
language: String
|
language: String
|
||||||
},
|
},
|
||||||
setup: setupForUseMeta(script => ({
|
setup: setupForUseMeta((props, { slots }) => {
|
||||||
script: [script]
|
const script = { ...props }
|
||||||
}))
|
const textContent = (slots.default?.() || [])
|
||||||
|
.filter(({ children }) => children)
|
||||||
|
.map(({ children }) => children)
|
||||||
|
.join('')
|
||||||
|
if (textContent) {
|
||||||
|
script.children = textContent
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
script: [script]
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// <noscript>
|
// <noscript>
|
||||||
|
Loading…
Reference in New Issue
Block a user