Stop Fighting Sanity's Portable Text - Here's How to Use Markdown Instead
dev.to·1d·
Discuss: DEV

Let me tell you about the worst hour of my Tuesday.

I wrote a 2,000-word blog post in Notion. Beautiful formatting, perfect headings, code blocks, the works. Then I tried to publish it to my Sanity CMS.

One hour later, I was manually converting this:

## How to Use the API

Simply call the `fetchData()` function:

\`\`\`javascript
const data = await fetchData()
\`\`\`

Into this monstrosity:

{
_type: 'block',
style: 'h2',
children: [{ _type: 'span', text: 'How to Use the API' }]
},
{
_type: 'block',
children: [
{ _type: 'span', text: 'Simply call the ' },
{ _type: 'span', text: 'fetchData()', marks: ['code'] },
{ _type: 'span', text: ' function:' }
]
},
{
_type: 'code',
language: 'javascript',
code: 'const data = await fetchData()'
}

I literally said out…

Similar Posts

Loading similar posts...