-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,487 additions
and
2,816 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './dist/content' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
title: Nuxt Content | ||
description: Integrating Nuxt SEO with Nuxt Content. | ||
--- | ||
|
||
## Introduction | ||
|
||
Most Nuxt SEO modules integrates with Nuxt Content out of the box. | ||
|
||
- Nuxt Robots: `robots` ([docs](/docs/robots/guides/content)) | ||
- Nuxt Sitemap: `sitemap` ([docs](/docs/sitemap/guides/content)) | ||
- Nuxt OG Image: `ogImage` ([docs](/docs/og-image/integrations/content)) | ||
- Nuxt Schema.org: `schemaOrg` ([docs](/docs/schema-org/guides/content)) | ||
- Nuxt Link Checker: Uses content APIs to check links | ||
|
||
For Nuxt Content v3 you would need to configure the modules to work with Nuxt Content individually, however, Nuxt SEO | ||
provides a way to configure all modules at once. | ||
|
||
For Nuxt Content v2, please see the individual module documentation for how to configure them. | ||
|
||
## Setup Nuxt Content v3 | ||
|
||
In Nuxt Content v3 we need to use the `asSeoCollection()`{lang="ts"} function to augment any collections | ||
to be able to use the SEO modules. | ||
|
||
```ts [content.config.ts] | ||
import { defineCollection, defineContentConfig } from '@nuxt/content' | ||
import { asSeoCollection } from '@nuxtjs/seo/content' | ||
|
||
export default defineContentConfig({ | ||
collections: { | ||
content: defineCollection( | ||
asSeoCollection({ | ||
type: 'page', | ||
source: '**/*.md', | ||
}), | ||
), | ||
}, | ||
}) | ||
``` | ||
|
||
To ensure the tags actually gets rendered you need to ensure you're using the SEO composable. | ||
|
||
```vue [[...slug].vue] | ||
<script setup lang="ts"> | ||
import { queryCollection, useRoute } from '#imports' | ||
const route = useRoute() | ||
const { data: page } = await useAsyncData(`page-${route.path}`, () => { | ||
return queryCollection('content').path(route.path).first() | ||
}) | ||
if (page.value?.ogImage) { | ||
defineOgImage(page.value?.ogImage) // <-- Nuxt OG Image | ||
} | ||
// Ensure the schema.org is rendered | ||
useHead(page.value.head || {}) // <-- Nuxt Schema.org | ||
useSeoMeta(page.value.seo || {}) // <-- Nuxt Robots | ||
</script> | ||
``` | ||
|
||
Due to current Nuxt Content v3 limitations, you must load the Nuxt SEO module before the content module. | ||
|
||
```ts | ||
export default defineNuxtConfig({ | ||
modules: [ | ||
'@nuxtjs/seo', | ||
'@nuxt/content' // <-- Must be after @nuxtjs/seo | ||
] | ||
}) | ||
``` | ||
|
||
## Usage | ||
|
||
For the full options available for each module, please see the individual module documentation. | ||
|
||
```md | ||
--- | ||
ogImage: | ||
component: HelloWorld | ||
props: | ||
title: "Hello World" | ||
description: "This is a description" | ||
image: "/hello-world.png" | ||
sitemap: | ||
lastmod: 2025-01-01 | ||
robots: index, nofollow | ||
schemaOrg: | ||
- "@type": "BlogPosting" | ||
headline: "How to Use Our Product" | ||
author: | ||
type: "Person" | ||
name: "Jane Smith" | ||
datePublished: "2023-10-01" | ||
--- | ||
|
||
# Hello World | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.