I have a document type which sometimes has a page and sometimes does not, and this depends on whether it is tagged with a particular tag or not.
In my application code I can easily check for this tag and render a link or not as appropriate when I'm looping through documents of this type.
I can do the same in my custom HTML serializer to cover the case where links are in rich text, though this would be a pain if I didn't already have my own HTML serializer.
That made it occur to me that it doesn't look like there's any built-in support for this use case. The typings for LinkResolver (in prismic-reactjs at least) say that it non-optionally returns a string, and the HTML serializer code doesn't check the link resolver's result, just goes ahead and throws it in the
In other documentation you seem to have mixed conventions -- in this doc one example falls back to
/ and another falls back to
/doc/<id>. But I want the hint to get to my application that it shouldn't render a link at all.
I think it would be good if link resolvers could return
undefined, whatever you prefer) in cases where there is no URL for that document. The SDK code should then support that and avoid rendering links as appropriate.
I think what I'll do for now is return the empty string and handle that specially in my codebase. I'll also need to tell my preview mode handler to handle that empty string and return the home page URL.