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

Is it possible to save in the data a reference to the contentful entry rather than storing the actual used text? #905

Open
saadshahd opened this issue Feb 19, 2025 · 2 comments

Comments

@saadshahd
Copy link

saadshahd commented Feb 19, 2025

I wonder if it's possible to use puck to store a reference of the external source when the external field is used.

Instead of saving the actual text, I want the reference of the entry so I could resolve the text in the correct language.

Puck users are only using english they are meant to focus on the design aspect, we have a contentful space where we keep our text and media assets where copy writers, write in english and sync with Crowdin to get translations from the specialised team.

The translation team publishes the contentful entries in all the remaining language. So It makes sense for the designers to work once and be able to view the text in any language the copy is defined in

@FedericoBonel
Copy link
Collaborator

Hello @saadshahd!

Puck is unopinionated about how you store your data, so you can handle this just like you would with any other React component.

One approach you could take is to create a custom field with an external AutoField inside. That way, before calling the onChange function you receive inside custom fields, you’d filter out the text and only pass the reference to it as the new value.

In your component config’s render function, you’ll then receive just that reference and can use it however you want—whether that’s fetching the actual translation, rendering only the reference, using it for additional logic, or something else entirely.

Let me know if that helps!

@saadshahd
Copy link
Author

Hello @saadshahd!

Puck is unopinionated about how you store your data, so you can handle this just like you would with any other React component.

One approach you could take is to create a custom field with an external AutoField inside. That way, before calling the onChange function you receive inside custom fields, you’d filter out the text and only pass the reference to it as the new value.

In your component config’s render function, you’ll then receive just that reference and can use it however you want—whether that’s fetching the actual translation, rendering only the reference, using it for additional logic, or something else entirely.

Let me know if that helps!

Thank you @FedericoBonel. I will try and share with you the result.

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

No branches or pull requests

2 participants