content icon indicating copy to clipboard operation
content copied to clipboard

JSON file data not show complete

Open Benbinbin opened this issue 2 years ago • 0 comments

Environment

  • Operating System: Windows_NT
  • Node Version: v16.16.0
  • Nuxt Version: 3.0.0-rc.6
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: modules
  • Runtime Modules: @nuxt/[email protected]
  • Build Modules: -

Reproduction

https://github.com/Benbinbin/nuxt-content-json

Describe the bug

After I upgrade the @nuxt/content to latest, the queryContent() composition api not work for JSON file, it cann't fetch the complete data of JSON file, it just get the metadata of the file.

For example the /content/test.json shown below

{
  "test": "test content"
}

but when I visit the http://localhost:3000/test the data got by queryContent() composition api (I just use the <ContentDoc> component which use queryContent() composition api to fetch data under the hook) contains the title and some built-in properties with the _ prefix, but not contain the custom test property in the JSON file

{
  "message": "You should use slots with <ContentDoc>",
  "slot": "default",
  "data": {
    "_path": "/test",
    "_draft": false,
    "_partial": false,
    "_locale": "en",
    "_id": "content:test.json",
    "_type": "json",
    "title": "Test",
    "_source": "content",
    "_file": "test.json",
    "_extension": "json"
  }
}

I try to downgrade the @nuxt/content version, when I catch the @nuxt/[email protected] the data get work again.

Additional context

I think the version @nuxt/[email protected] (generate by this commit) causes this bug, and the newer versions still have this bug.

Logs

No response

Benbinbin avatar Aug 10 '22 14:08 Benbinbin