Skip to content

Commit b72768b

Browse files
committedJan 20, 2025
fix(content): warn when nuxt content is loaded first
1 parent c9a074d commit b72768b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
 

‎docs/content/2.guides/3.content.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,22 @@ const { data: page } = await useAsyncData(`page-${route.path}`, () => {
4040
return queryCollection('content').path(route.path).first()
4141
})
4242
// Ensure the SEO meta tags are rendered
43-
useSeoMeta(page.value.seo)
43+
useSeoMeta(page.value?.seo || {})
4444
</script>
4545
```
4646

47+
Due to current Nuxt Content v3 limitations, you must load the robots module before the content module.
48+
49+
```ts
50+
export default defineNuxtConfig({
51+
modules: [
52+
'@nuxtjs/robots',
53+
'@nuxt/content' // <-- Must be after @nuxtjs/robots
54+
]
55+
})
56+
```
57+
58+
4759
## Setup Nuxt Content v2
4860

4961
In Nuxt Content v2 markdown files require either [Document Driven Mode](https://content.nuxt.com/document-driven/introduction) or a `path` key to be set

‎src/module.ts

+3
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ export default defineNuxtModule<ModuleOptions>({
335335
const isNuxtContentV3 = usingNuxtContent && await hasNuxtModuleCompatibility('@nuxt/content', '^3')
336336
let isNuxtContentV2 = usingNuxtContent && await hasNuxtModuleCompatibility('@nuxt/content', '^2')
337337
if (isNuxtContentV3) {
338+
if (nuxt.options._installedModules.some(m => m.meta.name === 'Content')) {
339+
logger.warn('You have loaded `@nuxt/content` before `@nuxtjs/robots`, this may cause issues with the integration. Please ensure `@nuxtjs/robots` is loaded first.')
340+
}
338341
// @ts-expect-error runtime type
339342
nuxt.hooks.hook('content:file:afterParse', (ctx) => {
340343
if (typeof ctx.content.robots !== 'undefined') {

0 commit comments

Comments
 (0)