Skip to content
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

improve MDX Components #113

Closed
onemen opened this issue Jul 21, 2023 · 4 comments
Closed

improve MDX Components #113

onemen opened this issue Jul 21, 2023 · 4 comments

Comments

@onemen
Copy link
Contributor

onemen commented Jul 21, 2023

ExercisePartRoute component get bloated with all the MDX component that are defined inline.

what do you think about move

<Mdx
	code={data.exerciseStepApp?.instructionsCode}
	components={{
		CodeFile,
		CodeFileNotification,
		DiffLink,
		InlineFile,
		LinkToApp,
		pre: PreWithButtons,
	}}
/>

with all the components list to a new file or to utils/mdx.tsx, then you can import ExerciseMdx and wrap it with useMemo if needed.

another improvement is to add remark plugin to validate inputs to Mdx components to prevents

- to <InlineFile file="app/routes/users_+/$username.tsx" /> so we can handle
+ to <InlineFile file="app/routes/users+/$username.tsx" /> so we can handle
@kentcdodds
Copy link
Member

I like both of these suggestions 👍

@onemen
Copy link
Contributor Author

onemen commented Jul 21, 2023

<InlineFile file="app/routes/users+/$username.tsx" />

Sometimes, InlineFile is used to create new files, so i can not check if app/routes/users+/$username.tsx exist, or event if the routes exist....

do you have any idea how to find if the there is an error in this case?
<InlineFile file="app/routes/users_+/$username.tsx" />

or another typo
<InlineFile file="app/routes/usrs+/$username.tsx" /> ?

@kentcdodds
Copy link
Member

We could have a "createFile" prop. If that isn't supplied then we error.

@kentcdodds
Copy link
Member

I've made a number of improvements since this was opened. I think we're good now.

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

No branches or pull requests

2 participants