Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relations support #69

Closed
not-vainglorious opened this issue Nov 13, 2022 · 3 comments
Closed

Relations support #69

not-vainglorious opened this issue Nov 13, 2022 · 3 comments
Labels
request Request for a feature

Comments

@not-vainglorious
Copy link

I made my own plugin for nextjs revalidation and got some your ideas but with improvements. I added support to relations and if you like to see it I can extend your logic and create new pull request for this feature.
Should mention that it will work a bit different. I will use custom back-end endpoint which will redirect to correct url because i'm using strapi metadata to verify all things and define correct populates and requesting entity by one single request. Also this one works only with manyToOne and oneToOne.

As example this works like this:

  {
          uid: 'api::building.building',
          query: {
            city: '{neighbourhood.city.slug}',
            neighborhood: '{neighbourhood.slug}',
            building: '{slug}',
          },
        },

Also when path ends with relation and not common field you will just get id so {neighbourhood.city} will add related city id to the query.

Reply to issue if you like it and i will make PR for this one.

@mattmilburn
Copy link
Owner

Hi @not-vainglorious I figured supporting relations would involve some extra API calls in the content manager 👍🏻 And yes I agree only manyToOne and oneToOne relations would be supported.

Happy to start working on a PR with you! 🙂

@mattmilburn mattmilburn added the request Request for a feature label Nov 16, 2022
@mattmilburn mattmilburn pinned this issue Nov 16, 2022
@mattmilburn
Copy link
Owner

@not-vainglorious 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.

@Shekhar-Zealous
Copy link

Hello @mattmilburn I want to create a custom url for preview button based on selected relation.

I tried extending the plugin as per your README but the hook is not working. Followed each steps just like it is mentioned.
The URL I want is https://sitename.com/page/{relation.fieldName}/{slug}. Can you please help me with a demo.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request Request for a feature
Projects
None yet
Development

No branches or pull requests

3 participants