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

feat: Nuxt Content v3 #398

Merged
merged 2 commits into from
Jan 17, 2025
Merged

feat: Nuxt Content v3 #398

merged 2 commits into from
Jan 17, 2025

Conversation

harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Jan 16, 2025

πŸ”— Linked issue

#393

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Setup Nuxt Content v3

In Nuxt Content v3 we need to use the asSitemapCollection(){lang="ts"} function to augment any collections
to be able to use the sitemap frontmatter key.

import { defineCollection, defineContentConfig } from '@nuxt/content'
import { asSitemapCollection } from '@nuxtjs/sitemap/content'

export default defineContentConfig({
  collections: {
    content: defineCollection(
      // adds the robots frontmatter key to the collection
      asSitemapCollection({
        type: 'page',
        source: '**/*.md',
      }),
    ),
  },
})

Usage

Frontmatter sitemap

Use the sitemap key in your frontmatter to add a page to your sitemap.

You can provide any data that you would normally provide in the sitemap configuration.

---
sitemap:
  loc: /my-page
  lastmod: 2021-01-01
  changefreq: monthly
  priority: 0.8
---

# My Page

Exclude from Sitemap

If you'd like to exclude a page from the sitemap, you can set sitemap: false in the frontmatter or robots: false
if you'd like to exclude it from search engines.

---
sitemap: false
robots: false
---

Copy link

vercel bot commented Jan 16, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
sitemap-edge-demo ❌ Failed (Inspect) Jan 16, 2025 11:22am

@harlan-zw harlan-zw merged commit 579f70e into main Jan 17, 2025
1 of 2 checks passed
@SomethingNew71
Copy link

Im not sure this is fully working with typescript. It appears it might be exported incorrectly?

Screenshot 2025-01-19 at 6 16 12β€―PM Screenshot 2025-01-19 at 6 16 17β€―PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants