Skip to content

Commit

Permalink
feat: Nuxt Content integration (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw authored Nov 24, 2024
1 parent 4a82606 commit 6dee1ca
Show file tree
Hide file tree
Showing 15 changed files with 1,034 additions and 455 deletions.
122 changes: 122 additions & 0 deletions docs/content/2.guides/1.content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
title: Nuxt Content
description: How to use the Nuxt Schema.org module with Nuxt Content.
---

## Introduction

Nuxt Schema.org integrates with Nuxt Content out of the box, supporting a `schemaOrg` frontmatter key that can be used to configure your pages
schema.org data.

You can see a demo of this integration in the [Nuxt OG Image & Nuxt Content Playground](https://stackblitz.com/edit/github-hgunsf?file=package.json).

## Setup

No extra set up is required, simply add the `schemaOrg` key to your frontmatter.

It's recommended to provide an array of Schema.org nodes, otherwise you will be extending the [`WebPage`{lang="ts"}](https://unhead.unjs.io/schema-org/schema/webpage) node with the provided data.

::code-group

```md [Array]
---
schemaOrg:
# Define new nodes
- "@type": "BlogPosting"
headline: "How to Use Our Product"
author:
type: "Person"
name: "Jane Smith"
datePublished: "2023-10-01"
---
```

```md [Object]
---
schemaOrg:
# Augment WebPage to an AboutPage
"@type": "AboutPage"
---
```

::

## Markdown Recipes

### Blog Post

```md
---
title: 'My Blog Post'
schemaOrg:
- type: "BlogPosting"
headline: "How to Use Our Product"
author:
type: "Person"
name: "Jane Smith"
datePublished: "2023-10-01"
---
```

### FAQ Page

```md
---
title: 'FAQ'
schemaOrg:
type: FaqPage
mainEntity:
- "@type": "Question"
name: "What is your return policy?"
acceptedAnswer:
"@type": "Answer"
text: "You can return any item within 30 days of purchase."
- "@type": "Question"
name: "Do you offer technical support?"
acceptedAnswer:
"@type": "Answer"
text: "Yes, we offer 24/7 technical support."
---
```

### About Page

```md
---
title: 'About'
schemaOrg:
"@type": "AboutPage"
---
```

### Contact Page

```md
---
title: 'Contact'
schemaOrg:
"@type": "ContactPage"
mainEntity:
"@type": "ContactPoint"
contactType: "Customer Service"
telephone: "+1-800-555-5555"
email: "support@example.com"
---
```


### Product Page

```md
---
title: 'Product'
schemaOrg:
- "@type": "Product"
name: "Product XYZ"
description: "A high-quality product that meets your needs."
offers:
"@type": "Offer"
price: "29.99"
priceCurrency: "USD"
---
```
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
},
"devDependencies": {
"@antfu/eslint-config": "^3.9.2",
"@nuxt/content": "^2.13.4",
"@nuxt/module-builder": "^0.8.4",
"@nuxt/schema": "^3.14.1592",
"@nuxt/test-utils": "^3.14.4",
Expand Down
Loading

0 comments on commit 6dee1ca

Please sign in to comment.