-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add a hook to modify the body
#10
Comments
Yeah I was thinking in adding some kind of hook to optionally use |
Thanks a lot! |
@yaquawa So I actually misunderstood what you needed here. What I meant was a hook to modify Harlem is basically adding function transformState(state) {
if (import.meta.env.SSR) {
state.harlem = getHarlemState()
return JSON.stringify(state)
} else {
// Restore Harlem's state to its place
window.__harlemState = JSON.parse(state.harlem)
return state
}
} The problem is that they don't provide a "getHarlemState" function out of the box but it can be easily done by using another function they provide: function getHarlemState() {
const script = getBridgingScript()
return script.slice(script.indexOf('=') + 1)
} It would be nice if they provide Tell me if this works for you (the transformState hook is implemented in 0.6.8). |
Good to know that, thanks for the detail! Also I've noticed that I could just write a little plugin for this using the transformIndexHtml hook. |
I'd been finding a way to append extra string to the
body
:vite-ssr/src/vue/entry-server.js
Line 60 in f0a7e02
Because I'm using this state management lib:
https://github.com/andrewcourtice/harlem/tree/main/plugins/ssr
to enable the SSR feature of it, it requires appending extra state data to the rendered string.
I wasn't able to find a way to do that, so would you add a hook that allows modify the
body
?Thanks!
The text was updated successfully, but these errors were encountered: