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

Using this with markdown remark #8

Open
cctoni opened this issue Mar 6, 2018 · 7 comments
Open

Using this with markdown remark #8

cctoni opened this issue Mar 6, 2018 · 7 comments

Comments

@cctoni
Copy link

cctoni commented Mar 6, 2018

Hey and at first thanks for this amazin plugin. What i want to achieve is to point gatsby to the repo and reading markdown files out of this and use with remark for generating the graphql schema. is there a way to do that ? Or maybe some pointings in the right direction

@ldd
Copy link
Owner

ldd commented Mar 16, 2018

Sorry for the late reply. Busy with work. You understand.
Did you manage to figure it out?
If I understand correctly, the issue is that you do not want only one file, like I already mentioned in this issue

you need many markdown files. I am not entirely sure how to do that, and I also would love to know.

@ldd
Copy link
Owner

ldd commented Aug 28, 2019

Closing this ticket mostly because we never found out how to do this.

However, anyone is free to open a new issue similar to this one, or to make further comments on this issue.

@ldd ldd closed this as completed Aug 28, 2019
@iloveip
Copy link

iloveip commented May 16, 2020

I have the same problem. I would like to be able to import multiple files from a GitHub repo as posts. Also I need them to be processed by allMdx, not allMarkdownRemark, as files are written in MDX

@ldd ldd reopened this May 16, 2020
@ldd
Copy link
Owner

ldd commented May 16, 2020

So now there are 2 people interested in that feature. I won't make any promises, but I'll take a look at it again.

It seems worth exploring.

@iloveip
Copy link

iloveip commented Jun 9, 2020

Hi there,
Do you have any update on this?

@ldd
Copy link
Owner

ldd commented Jun 14, 2020

So, I went ahead and finally got to investigate this issue.

The gist of it is that this plugin , right now, only generates one Node. Ideally, we'd want something like this:
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-hacker-news/src/gatsby-node.js

Once you have multiple Nodes, it is possible to mark some of them as having mediaType text/markdown and then Gatsby Transformers are able to transform them.

Sadly, I consider these changes to be non-trivial. And at the moment, I don't have the time to work on them.

But! PRs are welcome, and this issue will remain open. I guess you can also try to contact the author of gatsby-source-hacker-news or similar plugins to provide some guidance.

Finally, I am not saying that this is outside the scope of this project or that it cannot be fixed. In fact, this issue makes 100% sense. All that I am saying is that I cannot work on it right now.

:(

@jerboa88
Copy link

jerboa88 commented Aug 7, 2024

@ldd Thanks for the plugin!

Late to the party here, but if anyone is looking for more details on how to do this, here's a summary:

  1. When you perform a query using this plugin, it creates a single node of type GitHubData. In your gatsby-node.ts, you can implement the onCreateNode() function to listen for the creation of this node.

  2. You can then use createNode() to create new nodes with the data from the GitHubData node. When creating new nodes, if you set internal.mediaType to text/markdown and content to the README text, gatsby-transformer-remark plugin will automatically ingest the content and create a new node of type MarkdownRemark.

  3. You can then query the MarkdownRemark nodes to get the parsed content.

For MDX files, you can set internal.type to File and ext to .mdx when creating new nodes and it should work similarly, although I don't have any experience with this.

For reference, feel free to look at gatsby-node.ts and github-data-node-transformer.ts in one of my projects. I am basically fetching a list of repos and parsing the README of each one using gatsby-transformer-remark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants