ft-interactive / starter-kit

A template for IG pages
64 stars 15 forks source link

Update vike-v1 to work with Vike-React #349

Closed pandringa closed 2 months ago

pandringa commented 2 months ago

While reviewing #347 and reading through the Vike documentation, I realized that we should probably be using the vike-react framework — which is basically a bundled set of configuration options that implements much of the onRenderHTML and onRenderClient logic we had previously managed ourselves. This also changes the way our <head> tags and metadata are configured - those are now constructed in JSX via the /pages/+Head.jsx file, instead of our hacky ejs-templated HTML partial.

Vike-React has a slightly opinionated view of how to manage config, which I think actually suits us: there is a global pageContext/usePageContext() hook with server-side data about the request, then a separate data/useData() hook with client-side data sent along to the client.

For simplicity, right now I'm putting our entire context object in the data field - but I think it probably makes more sense to split up our context values and assign some of them to pageContext and keep data for the actual data loaded in.

aendra-rininsland commented 2 months ago

This is much nicer, thank you!