epicweb-dev / epicshop

The workshop app for all workshops on EpicWeb.dev
https://www.epicweb.dev
Other
194 stars 31 forks source link

improve MDX Components #113

Open onemen opened 1 year ago

onemen commented 1 year ago

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 commented 1 year ago

I like both of these suggestions 👍

onemen commented 1 year ago

<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 commented 1 year ago

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