Link to collection item specified with relation widget

I’m kind of stuck with how I could use the relation widget to link between two pieces of content.

I have a content type “Event” and I want to have “People” associated with that event. The widget saves only a string, so I can easily get the person’s name. But what if I want to link to the page for that person?

Would I need to be able extrapolate the link based on the name? That seems very prone to error. Is there some other trick? Can someone point me to some examples in the wild? I’m planning to use Eleventy/Nunjucks, but any working examples would be useful.

@freshyill You can use any field you want to index the relation using the valueField, but any field that changes will open you up to error once that value gets changed or deleted. You will have to account for this when resolving the relation in the project.

Thanks. It’s weird that the valueField doesn’t accept an array. That would make this much, much easier. I guess I will need to slugify the person’s name to make the link, and also use it in the permalink for people. I may just end up with some unwieldy URLs.

Not following why you want it an array? The valueField is the field, in the collection, you want to store as the index for reference back to the collection.

Unless I’m missing it, Netlify CMS doesn’t let me automatically generate an ID, or slug (in a field) or anything like that. So I just have to reuse a normal, manually entered field. Reusing the name, or the title of an article seems like it will break easily and often.

Is there a reliable way to do this? Is there maybe a way to store the original creation time in a hidden field and use that?

Yeah, that is what I was trying to say (poorly). It is an open issue you can track here and upvote:

1 Like

Thanks, I’ll keep an eye on this issue!