blog md sv # 3
Published at 2024/09/01
Getting this blog going… almost.
So… I decided to follow a blog post and finally get set up. Joy of Code posted about setting up markdown with mdsvex.
My branch got pretty stale as I tried to follow along (in javascript instead of typescript, and with an existing Svelte app instead of a fresh one as the blog described). I ended up checking in a partially working version that respects the metadata, but does not yet actually publish the posts. So I guess these words I am currently typing won’t be available to read until I fix that. But regardless, I think it’s important to keep your branches short-lived. Also, I think it’s super useful to get something that almost works out there, instead of keeping projects brewing forever unpublished. This is a stride towards that life for myself.
Dynamic Import
Dynamic imports with Svelte and Vite should enable me to snag all my posts (.md files). But something’s wrong with it - the blog does not match up with my directory structure and I think that’s causing me issues.
And so it was! My friend Matt helped me debug this situation. First off, he noticed that I was using ‘params.slug’ from the blog post, but I needed to use ‘params.entry’ because I used ‘entry’ in my directory’s name instead of ‘slug’. Then I noticed that for the import to succeed, I needed to start it with ‘./’ instead of just putting the wildcard. Finally, I was using a field to construct my ‘+page.svelte’ that wasn’t always present in my markdown metadata. The fix looks like this:
I also found that JSON.stringify was helpful in elucidating what the problem was, instead of just ‘String(post)’, which just showed that Object.