rehype-typst + Next.js + MDX #517
-
Hey there, first of all, thanks for all the work on typst.ts! I like to write in MDX for blogs and the like, and Next.js does a good job of generating pages from MDX files. Yesterday I worked on getting Issue 1Inability to compile // styled-jsx/dist/babel/index.js
var isStyledJsx = function(param) {
var el = param.node;
return lib$1.isJSXElement(el) && el.openingElement.name.name === "style" && el.openingElement.attributes.some(function(attr) {
// OLD: return attr.name.name === STYLE_ATTRIBUTE;
// NEW:
return attr.name?.name === STYLE_ATTRIBUTE;
});
}; I see two ways to fix this:
Issue 2React does not support namespaces in the
We can work around this by ignoring the react error in the {
"presets": [
[
"next/babel",
{
"preset-react": { "throwIfNamespace": false }
}
]
],
"plugins": []
} Perhaps one way to work around this is to add an option in I did some quick searching, but could not find an npm plugin to automatically convert SVG to JSX, but I found this online app, which is open source. So we could take a look and see how they do it, perhaps publish it as an npm package. Let me know what you think! I'll try to do the following at some point in the future:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
@Enter-tainer may help. I'll also look at it later. |
Beta Was this translation helpful? Give feedback.
-
make sense to me. although i dont think empty style tag is a bug.
i dont really know how next.js works. from rehype-typst's view, it convert typst code to hast and cannot see jsx or relevant things. maybe the solution should be turning some switches on. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the responses! I just tried out the latest Next.js version, including the app router. You can check out here: https://github.com/Loosetooth/next-rehype-typst-mdx As such you can ignore my opening comment above. I tried that out in an older project. |
Beta Was this translation helpful? Give feedback.
Thanks for the responses!
I just tried out the latest Next.js version, including the app router.
It works fine!
(With the exception of a hydration error, but that's not a big problem.)
You can check out here: https://github.com/Loosetooth/next-rehype-typst-mdx
As such you can ignore my opening comment above. I tried that out in an older project.
Seemingly, those issues have already been fixed one way or another.