vikejs / vike

🔨 Flexible, lean, community-driven, dependable, fast Vite-based frontend framework.
https://vike.dev
MIT License
3.87k stars 334 forks source link

markojs support #173

Closed dephiros closed 1 year ago

dephiros commented 2 years ago

Hi,

I am attempted to use this with markojs based on https://github.com/marko-js/examples/tree/master/examples/vite-express but got stuck. Appreciate some pointers

export { render }; // See https://vite-plugin-ssr.com/data-fetching export const passToClient = ["pageProps", "urlPathname"];

async function render(pageContext: PageContextBuiltIn & PageContext) { const { Page, pageProps } = pageContext; // const pageHtml = ReactDOMServer.renderToString( // // <Page {...pageProps} /> // // );

// See https://vite-plugin-ssr.com/html-head const { documentProps } = pageContext; const title = (documentProps && documentProps.title) || "Vite SSR app"; const desc = (documentProps && documentProps.description) || "App using Vite + vite-plugin-ssr";

const documentHtml = escapeInject`<!DOCTYPE html>

${title}
${Page.render(pageProps)}
`; return { documentHtml, pageContext: { // We can add some `pageContext` here, which is useful if we want to do page redirection https://vite-plugin-ssr.com/page-redirection }, }; } ``` - Replace all page*tsx with marko -
brillout commented 2 years ago

:+1: Let me know if you need something on vite-plugin-ssr's side to make it work.

brillout commented 2 years ago

cc @DylanPiercey @ryansolid

DylanPiercey commented 2 years ago

@dephiros @brillout I'm not sure how good a fit bringing Marko here is.

Mostly because Marko takes full control over the hydration process (IE the equivalent of page.client.jsx is automated by @marko/vite).

Not familiar enough with how things are setup in this project to say for sure that this would cause issues though.

brillout commented 2 years ago

Conceptually that should be fine. I don't know about the details, but it could work since vite-plugin-ssr is quite flexible really.

Someone'd need to dig.

brillout commented 1 year ago

Contribution much welcome to explore this.