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

export default class MyDocument 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>
          <title>Code Editor</title>
          <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>
    );
  }
}
