mikefowler / gatsby-plugin-collections

Create pages, with support for pagination and customizable permalinks, from a folder of Markdown files.
MIT License
11 stars 3 forks source link

Can't get plugin to work #4

Closed ItsJonQ closed 5 years ago

ItsJonQ commented 5 years ago

Hi there!

As a fan of Jekyll, I was super excited to see your plugin! Unfortunately, I wasn't able to get it to work :(.

These are the errors I'm getting from running gatsby develop

error Syntax Error: Expected Name, found }
error Plugin gatsby-plugin-collections returned an error

  Error: There was a problem getting content for your posts collection. This is probably not your fault.

  - createPages.js:109 Object.<anonymous>
    [gatsby-site]/[gatsby-plugin-collections]/lib/createPages.js:109:43

  - createPages.js:32 step
    [gatsby-site]/[gatsby-plugin-collections]/lib/createPages.js:32:23

  - createPages.js:13 Object.next
    [gatsby-site]/[gatsby-plugin-collections]/lib/createPages.js:13:53

  - createPages.js:4 fulfilled
    [gatsby-site]/[gatsby-plugin-collections]/lib/createPages.js:4:58

  - util.js:16 tryCatcher
    [gatsby-site]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [gatsby-site]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [gatsby-site]/[bluebird]/js/release/promise.js:569:18

  - promise.js:606 Promise._settlePromiseCtx
    [gatsby-site]/[bluebird]/js/release/promise.js:606:10

  - async.js:142 _drainQueueStep
    [gatsby-site]/[bluebird]/js/release/async.js:142:12

  - async.js:131 _drainQueue
    [gatsby-site]/[bluebird]/js/release/async.js:131:9

  - async.js:147 Async._drainQueues
    [gatsby-site]/[bluebird]/js/release/async.js:147:5

  - async.js:17 Immediate.Async.drainQueues
    [gatsby-site]/[bluebird]/js/release/async.js:17:14

This was for a brand new gatsby website with nothing but gatsby-transformer-remark setup. The site was generated with the latest Gatsby (v2.0.76) following these steps:

https://www.gatsbyjs.org/docs/quick-start

gatsby-plugin-collections was setup following your Quick Start docs:

https://github.com/mikefowler/gatsby-plugin-collections/blob/master/docs/quickstart.md

If there's something I'm missing, please let me know! Excited to hear from you :)

Thanks!

mikefowler commented 5 years ago

Hi @ItsJonQ! Would you post your gatsby-config.js for me to look at?

mikefowler commented 5 years ago

@ItsJonQ it would also be helpful to see the place(s) in your code that you're making GraphQL queries to fetch the collection content.

ItsJonQ commented 5 years ago

@mikefowler Hey! Thanks for getting back to me :D.

I just created a brand new Gatsby test project here:

https://github.com/ItsJonQ/gatsby-collections-test

From the out-of-the-box Gatsby generator, I've only added remark and collections: https://github.com/ItsJonQ/gatsby-collections-test/blob/master/gatsby-config.js#L14

The layout/post.js is here:

https://github.com/ItsJonQ/gatsby-collections-test/blob/master/src/layouts/post.js

(Copied from the docs)

From this setup, Gatsby is complaining with:

error Syntax Error: Expected Name, found }
error Plugin gatsby-plugin-collections returned an error

  Error: There was a problem getting content for your posts collection. This is probably not your fault.

  - createPages.js:109 Object.<anonymous>
    [gatsby-collections-test]/[gatsby-plugin-collections]/lib/createPages.js:109:43

  - createPages.js:32 step
    [gatsby-collections-test]/[gatsby-plugin-collections]/lib/createPages.js:32:23

  - createPages.js:13 Object.next
    [gatsby-collections-test]/[gatsby-plugin-collections]/lib/createPages.js:13:53

  - createPages.js:4 fulfilled
    [gatsby-collections-test]/[gatsby-plugin-collections]/lib/createPages.js:4:58

  - util.js:16 tryCatcher
    [gatsby-collections-test]/[bluebird]/js/release/util.js:16:23

  - promise.js:512 Promise._settlePromiseFromHandler
    [gatsby-collections-test]/[bluebird]/js/release/promise.js:512:31

  - promise.js:569 Promise._settlePromise
    [gatsby-collections-test]/[bluebird]/js/release/promise.js:569:18

  - promise.js:606 Promise._settlePromiseCtx
    [gatsby-collections-test]/[bluebird]/js/release/promise.js:606:10

  - async.js:142 _drainQueueStep
    [gatsby-collections-test]/[bluebird]/js/release/async.js:142:12

  - async.js:131 _drainQueue
    [gatsby-collections-test]/[bluebird]/js/release/async.js:131:9

  - async.js:147 Async._drainQueues
    [gatsby-collections-test]/[bluebird]/js/release/async.js:147:5

  - async.js:17 Immediate.Async.drainQueues
    [gatsby-collections-test]/[bluebird]/js/release/async.js:17:14

Hope this helps!

mikefowler commented 5 years ago

@ItsJonQ Bug found, patched, and released! Try it out with gatsby-plugin-collections@^1.1.3.

ItsJonQ commented 5 years ago

@mikefowler Holy moly, that did it! Thank you so much!!

No more compile errors, and I can see the page listed on the 404, as expected:

Pages (6)
/
/404.html
/404/
/page-2/
/posts/2017/11/07/first/
/posts/2018/12/21/hello-world/

Feel free to close this one~! 🙌

P.S. If you need any help with this project (feature ideas, documentation, etc...) please let me know :). Besides the core Gatsby plugins/transformers, I think this is the most valuable and helpful one (even though I haven't used it yet).

It brings the "it just works" magic from Jekyll into the Gatsby ecosystem (which is much needed, IMO).

mikefowler commented 5 years ago

@ItsJonQ great! Feature ideas and documentation improvements are welcome!