We will combine our knowledge of Dynamic routing to pass a dynamic parameter to a function that will query a single post from our Sanity CMS. When we fetch our blog post data this is a great place to do some processing of the content that we get back. If you didn't process your blog post markdown, it would come back as a string which doesn't look too great on the page.
To make our markdown pretty we will install and use the MDSvex
library to use it's compile function and render our markdown.
We'll see that MDSvex
gives us a Promise from compile
because it's an async function so we'll use the Svelte await
block to conditionally show the post body when it is ready, otherwise we'll show a loading state.