Skip to content

Automate toolbox generation from exercise markdown #67

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

Closed
wants to merge 5 commits into from

Conversation

sansaid
Copy link
Collaborator

@sansaid sansaid commented Apr 6, 2022

A few changes being introduced which haven't been tested yet.

Initially, for each exercise we were creating a Lesson component 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 the Exercises folder 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

sansaid added 5 commits March 28, 2022 21:16
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
@netlify
Copy link

netlify bot commented Apr 6, 2022

Deploy Preview for cyf-blocks ready!

Name Link
🔨 Latest commit 38e3ba1
🔍 Latest deploy log https://app.netlify.com/sites/cyf-blocks/deploys/624e1cbd21195f00093e17ad
😎 Deploy Preview https://deploy-preview-67--cyf-blocks.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@sansaid sansaid changed the base branch from main to react April 13, 2022 17:44
@SallyMcGrath
Copy link
Member

@40thieves this looks great to me but I'm not a React person. I'd like to merge if you approve?

@sansaid
Copy link
Collaborator Author

sansaid commented Apr 25, 2022

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!

@sansaid sansaid closed this Apr 25, 2022
@SallyMcGrath
Copy link
Member

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
https://github.com/CodeYourFuture/project-rainbird/blob/main/client/src/Views/Help/Markdown/Markdown.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants