Open cctoni opened 6 years ago
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.
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.
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
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.
Hi there, Do you have any update on this?
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.
:(
@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:
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.
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
.
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.
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