import renderToString from 'preact-render-to-string'
// import { App } from './App'
import { MetadataContext, ServerContext } from './hooks'

import { RenderedPage } from '../shared/ssr'
import { App } from './App'

export default (url: string): RenderedPage => {
    const metadata = {}

    const html = renderToString(
        <MetadataContext.Provider value={metadata}>
            <ServerContext.Provider value={true}>
                <App url={url} />
            </ServerContext.Provider>
        </MetadataContext.Provider>
    )

    return { html, metadata }
}
