import { React, constants } from '../common';
import * as next from '@tdb/web/lib/server/document';

next.fastClick(); // Speed up clicks on mobile devices.

export default class Document extends next.Document {
  public static async getInitialProps(args: next.IDocumentGetInitialProps) {
    const page = next.renderCss(args);
    return { ...page };
  }

  public render() {
    const props = this.props as any;
    return (
      <html>
        <next.Head>
          <meta
            name={'viewport'}
            content={'width=device-width, initial-scale=1'}
          />
          <link rel={'icon'} type={'image/x-icon'} href={`/favicon.ico`} />
          <next.Stylesheet href={constants.URL.CSS} />
          <style dangerouslySetInnerHTML={{ __html: props.css }} />
        </next.Head>
        <body>
          <next.Main />
          <next.NextScript />
        </body>
      </html>
    );
  }
}
