mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 05:35: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>
|
||||
<Meta name="description" :content="`My page's ${dynamic} description`" />
|
||||
<Link rel="preload" href="/test.txt" as="script" />
|
||||
<Script>console.log("hello script");</Script>
|
||||
</Head>
|
||||
</Html>
|
||||
|
||||
|
@ -90,9 +90,19 @@ export const Script = defineComponent({
|
||||
/** @deprecated **/
|
||||
language: String
|
||||
},
|
||||
setup: setupForUseMeta(script => ({
|
||||
script: [script]
|
||||
}))
|
||||
setup: setupForUseMeta((props, { slots }) => {
|
||||
const script = { ...props }
|
||||
const textContent = (slots.default?.() || [])
|
||||
.filter(({ children }) => children)
|
||||
.map(({ children }) => children)
|
||||
.join('')
|
||||
if (textContent) {
|
||||
script.children = textContent
|
||||
}
|
||||
return {
|
||||
script: [script]
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// <noscript>
|
||||
|
Loading…
Reference in New Issue
Block a user