<commit_before>// @flow
/* eslint-disable global-require, import/no-extraneous-dependencies */
import React from 'react'
import Helmet from 'react-helmet'

import { StaticRouter } from 'react-router-dom'
import { StyleSheetServer } from 'aphrodite/no-important'
import { renderToString } from 'react-dom/server'
import { Provider } from 'react-redux'
import App from '../../../client/pages/Root'
import { store } from '../../../client/modules/store'
import config from '../../utils/config'
import build from '../../utils/template'

const manifest = require('../../../static/manifest.json')

// Production middlewares
module.exports = (req, res): * => {
  const { html, css } = StyleSheetServer.renderStatic((): string => {
    require('../../../client/utils/globalStyles')

    return renderToString(
      <Provider store={store}>
        <StaticRouter location={req.url} context={{}}>
          <App />
        </StaticRouter>
      </Provider>
    )
  })

  const helmet = Helmet.renderStatic()

  const document = build({
    helmet,
    html,
    head: `
      <style data-aphrodite>${css.content}</style>
      ${config('progressive.enabled') &&
        `<meta name="theme-color" content="${config('progressive.themeColor')}" />`}

      ${helmet.title.toString()}
      ${helmet.meta.toString()}
      ${helmet.link.toString()}<commit_msg>fix server-side rendering<commit_after>// @flow
/* eslint-disable global-require, import/no-extraneous-dependencies */
import React from 'react'
import Helmet from 'react-helmet'

import { StaticRouter } from 'react-router-dom'
import { StyleSheetServer } from 'aphrodite/no-important'
import { renderToString } from 'react-dom/server'
import { Provider } from 'react-redux'
import App from '../../../client/pages/Root'
import { store } from '../../../client/modules/store'
import config from '../../utils/config'
import build from '../../utils/template'

const manifest = require('../../../static/manifest.json')

// Production middlewares
module.exports = (req, res): * => {
  const { html, css } = StyleSheetServer.renderStatic((): string => {
    require('../../../client/utils/globalStyles')

    return renderToString(
      <Provider store={store}>
        <StaticRouter location={req.originalUrl} context={{}}>
          <App />
        </StaticRouter>
      </Provider>
    )
  })

  const helmet = Helmet.renderStatic()

  const document = build({
    helmet,
    html,
    head: `
      <style data-aphrodite>${css.content}</style>
      ${config('progressive.enabled') &&
        `<meta name="theme-color" content="${config('progressive.themeColor')}" />`}

      ${helmet.title.toString()}
      ${helmet.meta.toString()}
      ${helmet.link.toString()}
{'fraction_non_alphanumeric': 0.18178466076696165, 'fraction_numerical': 0.0, 'mean_word_length': 3.098187311178248, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3299565', 'n_tokens_mistral': 788, 'n_tokens_neox': 794, 'n_words': 175}