import ReactDOMServer from 'react-dom/server' ; import React from 'react' ; import { PageShell } from './PageShell' ; import { escapeInject , dangerouslySkipEscape } from 'vite-plugin-ssr' ; import logoUrl from './logo.svg' ; import type { PageContext } from './types' ; import type { PageContextBuiltIn } from 'vite-plugin-ssr' ; export { render } ; export const passToClient = [ 'pageProps' , 'urlPathname' ] ; async function render ( pageContext ) { const { Page , pageProps } = pageContext ; const pageHtml = ReactDOMServer . renderToString ( < PageShell pageContext = { pageContext } > < Page { ... pageProps } / > < /PageShell>); 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>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <link rel="icon" href="${ logoUrl }" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta name="description" content="${ desc }" />
        <title>${ title }</title>
      </head>
      <body>
        <div id="page-view">${ dangerouslySkipEscape ( pageHtml ) }</div>
      </body>
    </html>` ; return { documentHtml , pageContext : { } , } ; }