-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[docs] Convert Gatsby starter blog to MDX #14607
Comments
I think some of this work is being done with the move to themes. Hey @amberleyromo, can you chime in on how this might overlap with your efforts already in progress? |
I think this would be a great addition for sure! (for context I'm currently working on issue #14890 that's sort of just a bigger effort to move the existing guides on the gatsby-mdx site to .org, maybe we reopen #14258 for this) What do you think @marcysutton if this were added as an Advanced Tutorial? (since I imagine this'd probably be a little more step by step @spences10) The reference guides in the sidebar at Adding Components to Markdown with MDX sort of cover this from a more general approach so I think it could work on its own specific to the Gatsby starter blog. |
My biggest thought is this: should we just convert the starter blog to MDX for everyone, so they get it by default? I also agree that a tutorial under "Additional Tutorials" would help those who have already set up a blog pre-MDX. |
So after initially logging this issue I tried to convert the starter blog in codesandbox.io to get an idea of the steps involved:
That's the basic steps covered, the next part, adding the The next part, adding a root wrap module is where things start to break down, the codesandbox.io project will refuse to start and it becomes unworkable - I'm not really sure at this point if it's the code (more than likely) or codesandbox.io but the speed at which you can iterate is really hampered by this. So the initial guide I linked, for converting an existing blog to get your own components working in mdx is entirely possible but adding something to wrap all the page elements I have struggled with on several occasions now but I feel will give the most impact as you have the freedom to style every page element of your markdown which wasn't really an option with markdown remark without creating custom Because of these setbacks I was having I decided to do my own, from 'scratch' blog with mdx at the beginning. If anyone can give any guidance as to why the starter blog won't play nicely when you add in In the meantime I'm going to continue with creating my own documentation for making a blog from scratch with mdx and including styling with styled-components so I have a clear understanding of what's needed. |
My first recommendation would be to try doing it locally and skipping Codesandbox to eliminate that as a variable. There are also changes coming for plugins and docs this week that would be worth looking into ( |
It seems there is a lot of momentum MDX documentation at the present. At a minimum, for the end user, it might be helpful to triage the
This does not reflect
These changes may help with users trying to migrate OR install for the first time. |
Thanks for the heads up! There's already a PR open to fix those references: #15559 |
So, an update on where I am with this, this by the way has spawned a whole "lets make a blog from scratch" post from me which is turning out to be a wonderful learning experience. However! Onto this:
Ok, so after learning that So, next steps for me are to try do the same on Codesanbox.io, then probably record a video of me doing it then a write up. The reasoning for Codesandbox.io is the barrier to entry is reduced considerably due to not having to create a dev setup if they haven't got one already running. |
Ok, so here's what I have found in relation to getting the Gatsby Starter Blog converted to using MDX . What was causing the issues previously when I was trying to do this was adding ✖ 「wdm」:
ERROR in ./node_modules/gatsby-plugin-typography/.cache/typography.js
Module build failed (from
./node_modules/gatsby/dist/utils/webpack-hmr-hooks-patch.js):
Error: ENOENT: no such file or directory, open
'/sandbox/node_modules/gatsby-plugin-typography/.cache/typography.js'
@ ./node_modules/gatsby-plugin-typography/gatsby-browser.js 22:25-55
@ ./.cache/api-runner-browser-plugins.js
@ ./.cache/api-runner-browser.js
ℹ 「wdm」: Failed to compile. I have the sandbox here if anyone is interested in taking a look. So, without The furthest I got was being able to add a import { MDXProvider } from '@mdx-js/react';
import Highlight, { defaultProps } from 'prism-react-renderer';
import React from 'react';
const components = {
pre: props => (
<Highlight
{...defaultProps}
code={`
(function someDemo() {
var test = "Hello World!";
console.log(test);
})();
return () => <App />;
`}
language="jsx">
{({
className,
style,
tokens,
getLineProps,
getTokenProps,
}) => (
<pre className={className} style={style}>
{tokens.map((line, i) => (
<div {...getLineProps({ line, key: i })}>
{line.map((token, key) => (
<span {...getTokenProps({ token, key })} />
))}
</div>
))}
</pre>
)}
</Highlight>
),
};
export const wrapRootElement = ({ element }) => (
<MDXProvider components={components}>{element}</MDXProvider>
); The second issue comes in when I try get the props of the child component by replacing the code example with So, what I can do is cover the element styling and leave out this syntax highlighting until I understand what the issue is. Thoughts @marcysutton, @gillkyle? |
Wow, very detailed updates, thanks @spences10 🙂 There's been recent talk of converting the official blog starter to using the blog theme in the future. There's an existing That being said, the guide for converting to MDX seems like it could still be beneficial for people that don't want to use the theme or want to see more of the fine tuned stuff you've already learned about that process. |
Due to the difficulties I was having with the Gatsby starter blog I decided to do my own documentation from scratch (simple hello world) to fully fledged blog with syntax highlighting and react live code blocks. It's a basic outline that I still have to break up into sections to record videos for each section to accompany the prose and also some basic styling and layout. I was thinking if we can't work out what's going on with the starter blog use some of that content, but I guess you have a lot already, right @gillkyle? |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing! Thanks for being a part of the Gatsby community! 💪💜 |
Happy to close this, I see no reason for it to stay open with all the other pieces of working happening around this. Let me know if you have any objections, otherwise I'll close it before the start of next week 🙏 |
Sounds good thanks @spences10, I think it makes sense to let the other moving parts situate themselves and we can reopen this in the future. Thanks for investigating so much into this. The context helps other issues and PRs like #16166 |
@spences10 thanks for all your work on this, found this closed issue while I was playing with mdx and
I think it is worth considering getting I will try making a PR to add these changes to the |
Thanks @thomaswangio 🙏 That post has taken up a lot of my spare time as of late, it's nearly done too 🎉 For anyone else interested the URL will change when I publish it but the playlist of the videos is here: https://www.youtube.com/playlist?list=PLGi_uHe_v04DRZ58L_0O5cilalymkC7On Thanks! Closing again as I think it's been opened again in error. |
@spences10 Ahh no sorry I want to re-open to address these 2 issues:
I will work on some PR's! |
Closing this issue now that 2 PR's are in the works :) |
So, I'm confused as to why this was initially dismissed when I suggested this but then accepted when you made a PR for it @thomaswangio. What did I miss that you did not with your contribution? I thought that there was no need for this but Thomas manages to turn this around... I'd appreciate some feedback on what I didn’t do that Thomas did. Thanks |
Hey @spences10 the team actually decided to keep it the way it is. The reason I made the PR was because there's no up to date tutorial on converting blogs to MDX (yours was actually one of the most recent and it was still using mdx tag) |
Hey @spences10, I'm going to close this again as the team is still interested in keeping MDX out of the starter blog. That being said, we now have improved documentation on making the change to MDX and there are additional community starters that incorporate MDX out of the box. If you develop another we'd love to have you add it! https://www.gatsbyjs.org/contributing/submit-to-starter-library/ |
Summary
Add guide for converting the Gatsby starter blog to use MDX
I have put together a brief YouTube video a while back on doing it and made some documentation to go with it, it's a bit dated as it uses the
mdx/tag
and notmdx/react
so will need updating.I'd also like to cover the use of adding a
root-wrapper
for styling components.Motivation
To aid user adoption of using MDX with Gatsby
Halp!
I'm not entirely sure where this can live in the current documentation, anyone able to give guidance?
The text was updated successfully, but these errors were encountered: