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

beforeRender Props transformation #882

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jsjexpert
Copy link

@jsjexpert jsjexpert commented Feb 6, 2025

This PR is based on my own need but I hope it can be useful to others.

Puck (and Render) can now accept an externalData prop, ostensibly populated from a backend query such as on a Next.JS page.
image
image

A new beforeRender param is exposed in Component Config allowing for render-time transformations without mutating the saved data,
image

This allows for template substitution using shared global data and provides a live preview of the transformed data
image
image
image

Add externalData prop on Puck, appContext, DropZone
Add beforeRender transformProps to DropZone.
Expose beforeRender to user components.
Add HandlebarsHeader and HandlebarsText demonstrating render-time transformations using external data
Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
puck-docs ✅ Ready (Inspect) Visit Preview Feb 6, 2025 7:19pm

Copy link

vercel bot commented Feb 6, 2025

@jsjexpert is attempting to deploy a commit to the Measured Team on Vercel.

A member of the Team first needs to authorize it.

Rename function to beforeRenderProps in DropZone to avoid confusion with exported transformProps.
Add beforeRenderServerProps and externalData to ServerRender.
Remove unnecessary logging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant