Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nuxt): broken capo.js injectHead usage #22447

Merged
merged 9 commits into from
Aug 3, 2023
6 changes: 3 additions & 3 deletions packages/nuxt/src/head/runtime/plugins/capo.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CapoPlugin, injectHead } from '@unhead/vue'
import { CapoPlugin } from '@unhead/vue'
import { defineNuxtPlugin } from '#app/nuxt'

export default defineNuxtPlugin({
name: 'nuxt:head:capo',
setup () {
injectHead().use(CapoPlugin())
setup (nuxtApp) {
nuxtApp.vueApp._context.provides.usehead.use(CapoPlugin())
}
})
4 changes: 3 additions & 1 deletion packages/schema/src/config/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ export default defineUntypedSchema({
watcher: 'chokidar-granular',

/**
* Add the CAPO head plugin in order to render tags in of the head in a more performant way.
* Add the capo.js head plugin in order to render tags in of the head in a more performant way.
*
* @see https://rviscomi.github.io/capo.js/user/rules/
*/
headCapoPlugin: false
}
Expand Down
2 changes: 1 addition & 1 deletion test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ describe('head tags', () => {
expect(headHtml).toContain('<meta name="description" content="overriding with an inline useHead call">')
expect(headHtml).toMatch(/<html[^>]*class="html-attrs-test"/)
expect(headHtml).toMatch(/<body[^>]*class="body-attrs-test"/)
expect(headHtml).toContain('<script src="https://a-body-appended-script.com"></script></body>')
expect(headHtml).toContain('<script src="https://a-body-appended-script.com"></script>')

const indexHtml = await $fetch('/')
// should render charset by default
Expand Down
3 changes: 2 additions & 1 deletion test/fixtures/basic/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ export default defineNuxtConfig({
componentIslands: true,
reactivityTransform: true,
treeshakeClientOnly: true,
payloadExtraction: true
payloadExtraction: true,
headCapoPlugin: true
},
appConfig: {
fromNuxtConfig: true,
Expand Down