import * as React from 'react'
import Helmet from 'react-helmet'

import Header from '../components/Header'
import Footer from '../components/Footer'
import { Layout } from 'antd'

import '../index.less'
import './index.less'

interface DefaultLayoutProps extends React.HTMLProps<HTMLDivElement> {
  showFooter?: boolean
  headerBefore?: any
  location: {
    pathname: string
  }
}

class DefaultLayout extends React.Component<DefaultLayoutProps, {}> {
  public render() {
    const { location, showFooter = true, headerBefore = null } = this.props

    return (
      <Layout>
        <Helmet
          title="openscript"
          meta={[
            {
              name: 'description',
              content: 'Platform to maintain linux scripts',
            },
            {
              name: 'keywords',
              content: 'open-source, linux, script, package, package-manager',
            },
          ]}
        />
        <Header before={headerBefore} currentPathname={location.pathname} />

        <Layout.Content
          ref={'content'}
          style={{
            minHeight: showFooter
              ? 'calc(100vh - 102px)'
              : 'calc(100vh - 60px)',
          }}
        >
          {this.props.children}
        </Layout.Content>
        {showFooter ? <Footer /> : null}
      </Layout>
    )
  }
}

export default DefaultLayout
