mattmilburn/strapi-plugin-preview-button

How can I access relation fields ?

Closed this issue · 2 comments

Hello,

I have the following two collections Page and Category where

Page { slug: String, category: Category}
Category { slug: string }

and my Paths are generated in the following way /{category.slug}/{page.slug}

In the current state of the library, is it possible to achieve this use case? I looked for relation support, but I couldn't find it. Maybe I missed it.

If someone could point me up or could help would be really glad

Thanks

Hi @quiloos39 Funny you ask this because it was on my mind just the other day after I release v1.0.0 of the plugin, which features breaking changes.

I think we can achieve this by using the lodash get() function and allowing nested selectors like in your example. I will keep you updated once this is part of the plugin.

Hi @quiloos39 The preview button plugin has recently updated to v1.1.1 with a new feature to use a plugin/preview-button/before-build-url hook to modify the preview URL in a more advanced way. This should make it easy to populate relation data into the URL 👍🏻

See the Extending section of the README for full details.