gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.3k stars 10.31k forks source link

Can't get markdown to work #10874

Closed omarllm closed 5 years ago

omarllm commented 5 years ago

Markdown is not working and gatsby develop gives me errors

I'm trying to get markdown to work on the website by following Adding markdown guide and the guide on Actions suggested in the errors (and a tutorial on Youtube).

Steps to reproduce

That's the repo with the problem: https://github.com/anabcrypto/abcrypto

Expected result

When I would click on the Read More section, the website shouldn't redirect me to a 404 error page.

Actual result

I get an error page.

Environment

System: OS: Linux 4.19 Fedora 29 (Workstation Edition) 29 (Workstation Edition) CPU: (4) x64 Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz Shell: 4.4.23 - /bin/bash Binaries: Node: 11.3.0 - ~/.nvm/versions/node/v11.3.0/bin/node Yarn: 1.12.3 - /var/lib/snapd/snap/bin/yarn npm: 6.5.0 - ~/.nvm/versions/node/v11.3.0/bin/npm Languages: Python: 2.7.15 - /usr/bin/python Browsers: Firefox: 64.0 npmPackages: gatsby: ^2.0.85 => 2.0.85 gatsby-plugin-catch-links: ^2.0.9 => 2.0.9 gatsby-plugin-manifest: ^2.0.13 => 2.0.13 gatsby-plugin-offline: ^2.0.21 => 2.0.21 gatsby-plugin-react-helmet: ^3.0.5 => 3.0.5 gatsby-plugin-typography: ^2.2.4 => 2.2.4 gatsby-source-filesystem: ^2.0.12 => 2.0.12 gatsby-transformer-remark: ^2.1.19 => 2.1.19 npmGlobalPackages: gatsby-cli: 2.4.8 gatsby: 2.0.85

error Couldn't find the required xsel binary. On Debian/Ubuntu you can install it with: sudo apt install xsel

Error: Couldn't find the required xsel binary. On Debian/Ubuntu you can inst all it with: sudo apt install xsel

error UNHANDLED REJECTION

Error: Couldn't find the required xsel binary. On Debian/Ubuntu you can inst all it with: sudo apt install xsel

jgierer12 commented 5 years ago

Did you try installing xsel as suggested in the error log? If you did, what's the output of xsel --version?

omarllm commented 5 years ago

Xsel gave me that error even before, but everything worked just fine. I've installed it just to test, here are the results of gatsby info --clipboard now:

System: OS: Linux 4.19 Fedora 29 (Workstation Edition) 29 (Workstation Edition) CPU: (4) x64 Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz Shell: 4.4.23 - /bin/bash Binaries: Node: 11.3.0 - ~/.nvm/versions/node/v11.3.0/bin/node Yarn: 1.12.3 - /var/lib/snapd/snap/bin/yarn npm: 6.5.0 - ~/.nvm/versions/node/v11.3.0/bin/npm Languages: Python: 2.7.15 - /usr/bin/python Browsers: Firefox: 64.0 npmPackages: gatsby: ^2.0.85 => 2.0.85 gatsby-plugin-catch-links: ^2.0.9 => 2.0.9 gatsby-plugin-manifest: ^2.0.13 => 2.0.13 gatsby-plugin-offline: ^2.0.21 => 2.0.21 gatsby-plugin-react-helmet: ^3.0.5 => 3.0.5 gatsby-plugin-typography: ^2.2.4 => 2.2.4 gatsby-source-filesystem: ^2.0.12 => 2.0.12 gatsby-transformer-remark: ^2.1.19 => 2.1.19 npmGlobalPackages: gatsby-cli: 2.4.8 gatsby: 2.0.85

gatsby develop returned an error (this is not the full output of gatsby develop):

... error gatsby-node.js returned an error

ReferenceError: id is not defined ... warning Using the global graphql tag is deprecated, and will not be supported in v3. Import it instead like: import { graphql } from 'gatsby' in file: /home/ok/src/pages/blog.js warning The GraphQL query in the non-page component "/home/ok/src/templates/blogTemplate.js" will not be run. Exported queries are only executed for Page components. It's possible you're trying to create pages in your gatsby-node.js and that's failing for some reason.

If the failing component(s) is a regular component and not intended to be a page component, you generally want to use a (https://gatsbyjs.org/docs/static-query) instead of exporting a page query.

If you're more experienced with GraphQL, you can also export GraphQL fragments from components and compose the fragments in the Page component query and pass data down into the child component — http://graphql.org/learn/queries/#fragments success extract queries from components — 0.079 s success run graphql queries — 0.026 s — 7/7 283.11 queries/second success write out page data — 0.004 s success write out redirect data — 0.002 s ⠄ onPostBootstrapdone generating icons for manifest success onPostBootstrap — 0.181 s

info bootstrap finished - 4.983 s

Warning: React version not specified in eslint-plugin-react settings. See https://github.com/yannickcr/eslint-plugin-react#configuration .

sidharthachatterjee commented 5 years ago

Hey @omrllm

Just took a look at this. There are two issues here:

error gatsby-node.js returned an error ReferenceError: id is not defined

In gatsby-node.js your call to createPage includes id in context which is undefined as the error above suggests

Because of this, the pages aren't getting created successfully and you're seeing the 404

Secondly, the file at /src/pages/sweet-pandas-eating-sweets.md doesn't have a path key in the front matter

I've fixed both of these and sent you a PR at https://github.com/anabcrypto/abcrypto/pull/1

Happy building with Gatsby!

omarllm commented 5 years ago

I knew it wasn't a big thing, but I didn't know how to solve it.

I still have to learn a lot :+1:

Thank you very much @sidharthachatterjee!

sidharthachatterjee commented 5 years ago

No problem at all, @omrllm

Feel free to open issues for anything else, we're here to help!