Skip to content

Expose collections config & schemas via a useContent composable #3672

@maximepvrt

Description

@maximepvrt

While working on validating field formats against the generated JSON Schema, I found it difficult to access or inspect the schema associated with a collection.

It would be very helpful to have a composable such as useContent that could return:

  • the list of available collections
  • the JSON Schema associated with each collection

This would greatly simplify:

  • schema validation during development
  • testing edge cases (e.g. date vs datetime)
  • building custom tooling on top of Nuxt Content / Studio

What I tried

I attempted to access the collections directly using:

import { collections } from '#content/preview'

but without success, this resulted in an error and didn’t seem to be supported in this context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions