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

CodeImport.tsx is not being used and the current rehype plugin won't properly render mdx imports #61

Closed
cold-briu opened this issue Sep 21, 2023 · 1 comment

Comments

@cold-briu
Copy link
Contributor

  1. The codeImport function from src\lib\plugins\code-import.ts is actually making the job of extracting the content. ✅

  2. However its not being rendered by src\components\CodeImport.tsx but by src\components\Code.tsx ⚠️

  3. The src\lib\md-plugins.ts file exports the codeImport function from feat: render all docs #1 as remarkPlugins. ✅

4.The same src\lib\md-plugins.ts file exports another codeImport function from src\lib\plugins\rehype-code.ts ⚠️

  1. The second codeImport function specifies that node.name !== 'CodeImport' gets rendered by a 'code' element.

  2. Then, src\components\MDXRender.tsx maps 'code' elements to the Code.ts component

  3. The codeImport function from src\lib\plugins\rehype-code.ts Actually does the same as src\components\CodeImport.tsx by manually composing the elements.

//codeImport function from src\lib\plugins\rehype-code.ts

node.type = 'element';
node.tagName = 'pre';
const lang = node.attributes?.find((a: any) => a.name === '__language');
const code = h('code', { class: lang?.value }, content?.value);
node.children = [code];
vs
// src\components\CodeImport.tsx
return <pre className={language-${language}}>{content};

This issue was found during the elaboration of the installation guide. The main intention was to import content from other mdx files to compose another mdx file to be rendered by the app.

Trying to bypass the rehype plugin was not enough, in the mean time a "MDXIimport" component must be added as a hot fix.

@cold-briu cold-briu changed the title CodeImport.tsx is not being used. CodeImport.tsx is not being used and the current rehype plugin won't properly render mdx imports Sep 21, 2023
@cold-briu
Copy link
Contributor Author

Closed by #79

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

1 participant