Anyone using solid-social with solid-markdown?
I'm trying to figure out how to get solid-social to work with solid-markdown, if anyone is using both and could help it'd be much appreciated.
I have tried:
markdown containing:
The title converts from markdown to html fine
39 Replies
Hey, could you create a small repro? I haven't looked for a while into solid-social repo, but I'll see what's going on
I tried to reproduce it, but I'm not getting the same result.
Here it is: https://codesandbox.io/p/sandbox/solid-social-with-solid-markdown-tdf62z
In my main site it shows the markdown converted to html apart from the social components but in the repro, it shows neither converted.
This is a more complex issue - you are running it on solid start, which renders on server first. I'm not even sure if solid-social works on server - but I think it should.
Not sure about solid-markdown
But I don't think it does
yeah I think it must be to do with solid-social as I just tried it alone on my main project and got an error
The build system was reworked, and the support should be there, at least I think so.
GitHub
rework build system by modderme123 · Pull Request #1 · high1/solid-...
This helps this package work in SSR mode
Ok thank you for pointing me in the right direction, I'll try again. If I don't get it to work I might contact modderme123
Just give me a reproduction - but somewhere where I can make changes to the code without logging in, if possible - like StackBlitz?
Since you are using SSR, it would also be a good idea to use @mdx-js/mdx on demand.
And not render the markdown client side - if it's not a must.
https://stackblitz.com/edit/solid-ssr-vite-qyuqxf?file=src%2Froutes%2Findex.tsx
I'd like the markdown content to be rendered server side as I'm storing it in supabase database
There's some stuff missing in exports in solid-start, but it works in SSR, if you disregard hydration errors - I'll fix that as soon as I can. Your client side render function is async - that doesn't work in solid, I don't know if this is an error or it should work in solid start
About mdx, I do think that mdx on demand is doable
You could expose an API route that would return compiled MDX to the client and then run the code with solid/jsx-runtime, if I'm reading @mdx-js correctly
The code can be wrapped in a Dynamic component
https://stackblitz.com/edit/solid-ssr-vite-qyuqxf?file=src%2Froutes%2Findex.tsx
Ok I made a compileMarkdown util and used and , also removed async in there and then returned it inside a Dynamic component but it's still not working :/
Well, it's not going to work like that
That markdown string compiles to components, right?
So, you need
So let's say this is your server
You are missing the client code
So, it would look something like
You can't just slap async on a component and call async functions there, OK? Judging by that, I would say that you need to iterate more on understanding how to handle async stuff in Solid. The same principle and slightly different code (but more verbose) would be applied for React also.
I've decided to call the API inside onMount - this is not good, because why would I went for component mount when I can do this as soon as I start calculating?
use something like createResource for fetching when component starts
I'll release a version of solid-social as soon as I update the build process on GitHub
Here's a temporary build of 1.0 - you can just install it from a local fie
npm i ./solid-social-1.0.0.tgz
or path to folder with it
Huh, I don't think mdx on demand is going to work
oh ok, well thank you for trying to help me anyways
I'll try to make it work - I might be missing something, and this mode is not documented in the best way
I found this compileMarkdown function on github that might work.
https://github.com/lukaprsina/fizika/blob/fe6dfd9344c4e6fe93821a6167144ff9a2478464/web/src/components/Markdown.tsx#L194C14-L194C14
I can't test it at the moment as my laptop is freezing every few seconds
GitHub
fizika/web/src/components/Markdown.tsx at fe6dfd9344c4e6fe93821a616...
fizika.sc-nm.si. Contribute to lukaprsina/fizika development by creating an account on GitHub.
Compile works just fine
This is solid-mathjax, using newer version of solid-social
And it compiles your markdown using getResource function, and pretty much the same code that's on the @mdx-js website
I'm not sure why, but the provider wrapping does not work like this in Solid Start
Maybe I'm missing something?
Went to look for docs and misclicked on the first result
So, when the second part happens - the rendering of the component, it could very well be possible that this has to be done on onMount
This is render - but a client side render - using compile
So, when using this - you have to be careful when the parts are run
You would compile the markdown on the server, and then you would have to run the markdown render client side, and make sure that the client side is up and the provider is defined
I'm getting this error when trying this with and without the MDXProvider wrapper
_provideComponents is an alias for useMDXComponents
It comes from solid-jsx
So, you're not doing something right
import * as runtime from 'solid-jsx'
Huh strange because I commented out the provider from solid-jsx
that alias is set by @mdx-js
What you'll get is that YouTube component is missing - since it's not in the provider
If you set up things correctly
oh 1 sec lemme try something
ah yeah I was doing instead of probably missed it when I was copying imports from old non working ones
So now it works client side it should be able to work compiling server side then running client side as you mentioned before
Thank you so much, it's working with server side compiling now
Great. I'll update solid-jsx and solid-social next week, got some minor things to add. Most of the things here you could do without solid-jsx, as solid can now also be a jsxImportSource for @mdx-js, but there's no MDXProvider and useMDXComponents