harlan-zw / nuxt-seo

The complete SEO solution for Nuxt.
https://nuxtseo.com
MIT License
1.09k stars 70 forks source link

Position of changes from body to headd #335

Open KajKandler opened 1 month ago

KajKandler commented 1 month ago

Describe the bug

I have the following code in my [...slug].vue in Nuxt content

<script setup>
const route = useRoute()
const { data: page } = await useAsyncData('content', () => queryContent(route.path).findOne())

// Extract schema from the content's frontmatter
const schema = page.value.schema_org

// Use the nuxt-schema-org composable to add schema
if (schema !== undefined && schema != null) {
  useSchemaOrg(schema) // generates tag in body
} else {
  useSchemaOrg("") // generates tag in head
}
</script>

Depending on which call it makes the tag is generated in the head or body (see comments in the code)

Sidenote: When I call the useSchemaOrg() w/o parameters or a null or undefined value, it does not generate any schema tag.

Reproduction

No response

System / Nuxt Info

- Operating System: `Darwin`
- Node Version:     `v21.7.1`
- Nuxt Version:     `3.13.2`
- CLI Version:      `3.14.0`
- Nitro Version:    `2.9.7`
- Package Manager:  `npm@10.8.2`
- Builder:          `-`
- User Config:      `-`
- Runtime Modules:  `-`
- Build Modules:    `-`