Automate toolbox generation from exercise markdown#67
Conversation
The idea is to use HTML comments for block tags in markdown, so that we know from the markdown what is explicitely being referenced as a block
When parsing blocks, we'll need to know which categories they belong to. This file contains a static map, which should be updated when we added supported blocks (this assumes all block names are unique across the entire toolbox and not just to their category)
This bundles the exercise texts with their toolbox after parsing. The changes also introduces a ParseToolbox function which parses the exercise text to produce the toolbox needed
Instead of fetching the exercise texts (since that has to be done earlier now in order to parse the toolbox), we're changing the props for LessonMarkdown so it accepts the actual text will passed into ReactMarkdown
✅ Deploy Preview for cyf-blocks ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
|
@40thieves this looks great to me but I'm not a React person. I'd like to merge if you approve? |
|
Hey @SallyMcGrath ! I'm closing this, because I made some incorrect assumptions about how React works and this doesn't work at all. I've raised PR #78 if you want to take a look at the changes that actually work! |
|
Oh yes sorry @sansaid we (me and Ali) ended up discussing by DM which is a bad habit I will break. I was also making some wrong assumptions. To record here: the subject of our discussion was that I solved a similar problem a couple of weeks ago in another CYF project. It might be a mad solution -- like I said, I don't know React -- but it's here: https://github.com/CodeYourFuture/project-rainbird/blob/main/client/src/Content/MarkdownIndex.js |
A few changes being introduced which haven't been tested yet.
Initially, for each exercise we were creating a
Lessoncomponent from the imported exercise which was localised. The exercises were manually added to an array with their toolboxes manually created as well. This PR changes theExercisesfolder to be a flat structure which serves an array of the exercises and their toolboxes. It introduces a<!--block-->tag which we can wrap blocks in markdown to explicitly signal that we expect this block to be used in a toolbox. This is parsed and added into an object next to the markdown text of the exercises.View rendered client/src/Exercises/01-stuff.md
View rendered client/src/Exercises/02-more-stuff.md