pngwn / MDsveX

A markdown preprocessor for Svelte.
https://mdsvex.pngwn.io
MIT License
2.27k stars 96 forks source link

Returning markdown on first load in svelte kit #362

Open theClarkSell opened 2 years ago

theClarkSell commented 2 years ago

I'm at a loss looking for a little direction. Bug or I screwed up, I just don't know.

I've implemented our blog here: https://that.us/blog/ when you click on the posts everything renders as expected. It's when you go directly, what I would call the first load where it returns the raw markdown vs being rendered. Browse here https://that.us/blog/posts/2021-10-21-what-is-that/

The only thing I can gather is we're using load in sveltekit https://github.com/ThatConference/that.us/blob/master/src/routes/blog/posts/%5Bslug%5D.svelte#L1-L30

Mind you, this works locally, and it works in build/preview it just doesn't work in production. We run in vercel, but I can't honestly come up with what the difference would be.

I'm just at a loss as to what to look at next.

pngwn commented 2 years ago

Can you share the source? I need to see how you are routing/ fetching to understand the problem.

theClarkSell commented 2 years ago

yea it's all online. this is the load method mentioned above https://github.com/ThatConference/that.us/blob/a86874f10ad4675ae903a8ed5d2bba4ed9365200/src/routes/blog/posts/%5Bslug%5D.svelte#L1-L29 and here is how I'm grabbing the posts. https://github.com/ThatConference/that.us/blob/a86874f10ad4675ae903a8ed5d2bba4ed9365200/src/_blog/getPosts.js

From what I can gather. The server (load) is just responding with the markdown. Maybe kit's load isn't supported?

**updated links to point to a commit instead a things move pretty fast right now.

pngwn commented 2 years ago

Sorry, didn't read the links properly. I'll take a look.

theClarkSell commented 2 years ago

no worries at all, I really appreciate the help. I've tried to follow all of what people have put together and talked about. We'd love to capture the SEO and the perf gains from the load which is why I went down that route.

theClarkSell commented 2 years ago

well to throw more fuel on this fire. I was thinking I could just load that data client-side for now https://github.com/ThatConference/that.us/pull/1046 but the same thing is happening which leads me to, load isn't the problem and I am more confused.

theClarkSell commented 2 years ago

It looks like I found what was going on. I had my posts and images in the static folder. if I moved it out of that and under src things worked as expected on the first load. Still odd, but a pointer in the right direction.