Search code examples
next.jssanity

Internal Link not working in Body Text with PortableTextToReact


I followed this guide on creating an internalLink type to be used within body text for linking to other posts etc.

It states to use the mark however that is undefined, I can get data which returns the following

{
    "_key": "1c0ae3f78bac",
    "_type": "internalLink",
    "reference": {
        "_ref": "b8f67695-00e4-4906-8ba4-9c51faf093fb",
        "_type": "reference"
    }
}

How do I get the reference to be the slug.current of the actual post it is referencing to?


Solution

  • You'll want to make sure you're following the reference (->) in the GROQ query when you're querying the links.