Comments (5)
mmm yeah, there's probably going to be something like this. My big question is how the other sources work. If you're querying the graphql for mdx, then presumably you could also send it through the webpack loader right? I'm not super familiar with the other source plugins though and we'd probably need the mime-db PR to operate on other sources. Do other sources get persisted to disk? Can we just require them? Then the graphql query is mostly for metadata (and filesystem location) and every works just like the "natural" way too.
but, mdx also works in the browser, so maybe instead of querying for the component, you query for the raw(ish) source (minus frontmatter) and the importMDX
component just calls mdx.sync?
from gatsby-mdx.
I don't think this can function like other plugins since they source new nodes/fields into GraphQL, where we need to end up with a React component.
I like the idea of querying the source and then calling mdx.sync but I'm not sure that would play nicely with imports inside the MDX source.
from gatsby-mdx.
I'm actually having trouble coming up with a use case for being able to query the code and use it as a component. The ones I can come up with are overly convoluted and I can think of better ways to accomplish them (straight code imports, a structured JSON data, etc).
On the other hand, I do see a lot of use cases for being able to query the metadata (excerpts, time to read, etc).
Do you have a good use case in mind that we can target this functionality toward?
I also keep coming back to some kind of "createComponent" type API (similar to createPage
, but I'd like to hear a solid use case first so I can focus my thoughts a bit better.
from gatsby-mdx.
The only example I can find where this would be used so far is the React website. They query multiple markdown files and use them to build each row of the home page. https://github.com/reactjs/reactjs.org/blob/master/src/pages/index.js#L404
But with MDX, it would be dramatically easier since they could import the files as components and skip the query.
I'm thinking that this might be a non-issue. Unless we can think of a good reason for this, I'm for closing this issue and removing the code
GraphQL field.
from gatsby-mdx.
I'd hold off on removing the field. Maybe just have it there undocumented for some enterprising soul to find a solid use case (or my own experiments to find one lol).
The best argument I can see for this is that it's what users want to do and if they keep running into "this is how I expect it to work and it doesn't work this way" then we could put more effort into supporting it.
from gatsby-mdx.
Related Issues (20)
- update npm for gatsby-plugin-mdx to show up the deprecation notice HOT 1
- Some HTML comments cause an Unexpected Token error
- using the words `import actions from` breaks the parser.
- Release next mdx-utils version HOT 7
- Error processing latex with curly braces using remark-math, remark-html-katex plugins
- Unable to follow docs to perform a graphql page query HOT 3
- Extra backslash sometimes inserted when using $ in text HOT 3
- Local (Remark) Plugin does not resolve HOT 1
- Bug or Feature? Are Tags 0.6.2 -> 1.0.6 releases? Document on NPM that there's a new package name. HOT 2
- Remark-Sectionize doesn't work after the upgrade to Mdx 1x
- [bug] path url is null when creating page from mdx file HOT 2
- Bug when using MDXRenderer + Large Markdown Files + PrismJS HOT 13
- Default Layout issue HOT 4
- npm / Gatsby search using old Readme stating "gatsby-mdx is the official integration" HOT 8
- change-case in gatsby-mdx not listed in dependencies HOT 1
- Issue with code blocks containing parenthesis and brackets HOT 1
- Adding new imports requires full restart
- Permalinks missing? HOT 5
- About using node.excerpt onCreateNode
- GraphiQL error with html field HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gatsby-mdx.