code-hike / codehike

Marvellous code walkthroughs
https://codehike.org
MIT License
4.41k stars 136 forks source link

CH.Slideshow throws an error when there is no code block for a slide #227

Closed brianespinosa closed 1 year ago

brianespinosa commented 1 year ago

It would make more sense if we could just render whatever the MDX is for the slide instead of the code hike code/example in the north pane in any scenario where there is no code block. This might give the option for others to create slides in between a code walkthrough.

I think the challenge might be that we are parsing the contents of a slide and anything outside of a code block is being interpreted as a slide note. My suggestion above might only be possible if we made a change to how the slide notes were parsed. One possibility would be having a CH.SlideNotes component to contain them in a slide, or possibly by adding frontmatter support per slide.

pomber commented 1 year ago

Missing code shouldn't throw an error anymore since v0.7.0-next.2.When a step doesn't have code it shows the code from the previous step.

But that's probably not what you are suggesting. Can you provide a small example to see if I understand?

brianespinosa commented 1 year ago

The fix in 0.7.0 RC2 is what I need. Thanks! I'll keep an eye out for the next minor release.

Admittedly... this was a bug report with a hidden feature request attached to it. I must have put on my product manager hat last night.

brianespinosa commented 1 year ago

I saw 0.7.0 was released and updated locally and I am still seeing the issue, though I suspect it may be because I am using next-mdx-remote in my implementation. Let me dig a bit more today and I should be able to also share some working examples of what I am seeing with a public repo.

Thanks for all your work on codehike btw. Great stuff.

pomber commented 1 year ago

Maybe try to reproduce it in the playground: https://play.codehike.org/

brianespinosa commented 1 year ago

@pomber Yes, I was able to reproduce and turns out I guess that this is expected, at least in the first slide as the error message "The first step should have some code" is in steps.tsx

pomber commented 1 year ago

Yes, that's intended, if a step doesn't have code it uses the code from the previous step.

I'll close this one. If that error still blocks your use case, feel free to create a new issue.