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

Fetching CSV not working with custom delimiter? + outdated codesandbox #304

Closed
thely opened this issue Jul 28, 2020 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@thely
Copy link

thely commented Jul 28, 2020

Version

@nuxt/content: 1.5.0
nuxt: 2.13

Reproduction Link

https://codesandbox.io/s/nuxtcontent-demo-k565s?file=/pages/_slug.vue

NOTE: the default nuxt/content codesandbox that we're asked to fork on new issues can't get a nuxt/content release beyond 0.3.0. So this sandbox is experiencing a completely different issue, because options doesn't exist before 1.3.0, but it's what I have.

Steps to reproduce

Get a tab-delimited CSV file. Attempt to use the {delimiter: "\t"} option with it; it breaks (on later versions of content, it doesn't break, but it also doesn't use the delimiter). Try removing the options object, so the top line reads const test = await $content("test"). It works, but only without options.

What is Expected?

I want to be able to load in a tab-delimited CSV file, and figured I could use the csvtojson parameters in an options object.

What is actually happening?

The custom delimiter doesn't work. It still just has a bunch of \ts all over the place.

@thely thely added the bug Something isn't working label Jul 28, 2020
@thely
Copy link
Author

thely commented Jul 29, 2020

Figured it out. I was running in the wrong direction because I thought the options discussed in the docs on Fetching Content were what I'd use to define the delimiter, when it actually needed to be defined in nuxt.config.js, as described in Configuration. The codesandbox above now reflects this.

I did also realize that the release number was limited to 0.3.0 because of the difference between @nuxtjs/content and @nuxt/content, but I'm leaving this open still because the fork-able codesandbox needs to be updated.

@atinux
Copy link
Member

atinux commented Aug 2, 2020

The sandbox has been updated @thely

Sorry for the delay: https://codesandbox.io/s/nuxt-content-l164h

@maxime-ducoroy
Copy link

Hi @benjamincanac ,
Could you reopen this issue please
I have the same error:
Nuxt: 3.13.2
Nuxt-Content: 2.13.4

And in my Nuxt config:

content: {
    csv: {
      delimeter: ';'
    }
  }

My CSV file

Col1;Col2;Col3
Data1;Data2;Data3

Result of ContentDoc :

{
  "message": "You should use slots with <ContentDoc>",
  "slot": "default",
  "data": {
    "_path": "/test",
    "_dir": "",
    "_draft": false,
    "_partial": false,
    "_locale": "",
    "_id": "content:test.csv",
    "_type": "csv",
    "body": [
      {
        "Col1;Col2;Col3": "Data1;Data2;Data3"
      }
    ],
    "title": "Test",
    "_source": "content",
    "_file": "test.csv",
    "_stem": "test",
    "_extension": "csv"
  }
}

ExpectedResult :

{
  "message": "You should use slots with <ContentDoc>",
  "slot": "default",
  "data": {
    "_path": "/test",
    "_dir": "",
    "_draft": false,
    "_partial": false,
    "_locale": "",
    "_id": "content:test.csv",
    "_type": "csv",
    "body": [
      {
        Col1: "Data1",
        Col2: "Data2",
        Col3: "Data3"
      }
    ],
    "title": "Test",
    "_source": "content",
    "_file": "test.csv",
    "_stem": "test",
    "_extension": "csv"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants