dynamic routes links in Next.js with Markdown data

Viewed 270

How do I deal with dynamic routes in Next.js with Markdown data from a CMS? I've been trying to figure out the best approach to dealing with dynamic links in Next.js. I have a body of text in markdown from a Datocms API like this:

     content:
      '[Nulla kevin salami](/posts/mistakes-tourists-make-on-their-first-trip-abroad) dolor dolore ball tip lorem ut buffalo meatloaf ribeye. Consequat jowl est do. Pork meatball shankle, brisket dolore eu fugiat tenderloin corned beef veniam pork loin burgdoggen chuck sed. Nulla andouille ham jerky esse rump ipsum do.'

I'm new to markdown, but I know i'll need to convert it to HTML. But in this sample text, I've added a link to another post in Next.js. This link works just fine, but it isn't using next/link to refer to the route and the slug.

So how do I parse this markdown, figure out if link is internal/external, and return the right component using next/link? Is this really not a big deal unless I intend on using this for a static site?

Doesn't anyone have thoughts? Thanks so much for your help!

0 Answers
Related