import PropTypes from 'prop-types'
import Head from 'next/head'

import Navigasyon from './navigasyon'

const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000'
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:1337'

export default function HeadLayout({
  children,
  imageUrl,
  imageWidth,
  imageHeight,
  imageMime,
  title,
  tab,
  slug
}) {
  return (
    <div>
      <Head>
        <title>#OKi | {title ? title : 'Organisation KA Internationale'}</title>
        <link rel='canonical' href={`${slug ? `${siteUrl}/${slug}` : siteUrl}`} />
        <link rel='manifest' href='/manifest.json' />
        <link rel='icon' type='image/x-icon' sizes='128x128' href='/favicon.ico' />
        <link rel='apple-touch-icon' href='/favicon.ico' />
        <meta name='application-name' content='#OKi | Organisation KA Internationale' />
        <meta name='twitter:card' content='summary' />
        <meta name='twitter:url' content={`${slug ? `${siteUrl}/${slug}` : siteUrl}`} />
        <meta name='twitter:title' content={`${title ? title : '#OKi | Organisation KA Internationale'}`} />
        <meta name='twitter:description' content='Organisation KA Internationale. Paroles, traductions et Fediverse' />
        <meta name='twitter:image' content={`${imageUrl ? `${apiUrl}${imageUrl}` : `${siteUrl}/oki-logo-192x192.png`}`} />
        <meta name='twitter:creator' content='@OrganisationKA' />
        <meta name='twitter:site' content='@OrganisationKA' />
        <meta name='theme-color' content='#303030' />
        <meta name='apple-mobile-web-app-status-bar' content='#303030' />
        <meta charSet='utf-8' />
        <meta name='description' content='Organisation KA Internationale a pour but de promouvoir les langues et les productions afro-diasporiques. Fediverse ➡️ o-k-i.net' />
        <meta name='author' content='#OKi' />
        <meta name='viewport' content='minimum-scale=1, initial-scale=1, width=device-width' />
        <meta property='og:url' content={`${slug ? `${siteUrl}/${slug}` : siteUrl}`} />
        <meta property='og:type' content='website' />
        <meta property='og:site_name' content={`${title ? title : '#OKi | Organisation KA Internationale'}`} />
        <meta property='og:title' content={`${title ? title : '#OKi | Organisation KA Internationale. Paroles, traductions et Fediverse'}`} />
        <meta property='og:description' content='Organisation KA Internationale a pour but de promouvoir les langues et les productions afro-diasporiques. Fediverse ➡️ o-k-i.net' />
        <meta property='og:locale' content='fr_FR' />
        <meta property='og:image' content={`${imageUrl ? `${apiUrl}${imageUrl}` : `${siteUrl}/oki-logo-512x512.png`}`} />
        <meta property='og:image:secure_url' content={`${imageUrl ? `${apiUrl}${imageUrl}` : `${siteUrl}/oki-logo-512x512.png`}`} />
        <meta property='og:image:type' content={imageMime ? imageMime : 'image/png'} />
        <meta property='og:image:width' content={imageWidth ? imageWidth : '512'} />
        <meta property='og:image:height' content={imageHeight ? imageHeight : '512'} />
        <meta property='og:image:alt' content={`${title && imageUrl ? title : '#OKi Logo'} | Organisation KA Internationale`} />
      </Head>
      <Navigasyon selectedTab={tab} />
      {children}
    </div>
  )
}

HeadLayout.propTypes = {
  children: PropTypes.node.isRequired,
  imageUrl: PropTypes.string,
  imageWidth: PropTypes.number,
  imageHeight: PropTypes.number,
  imageMime: PropTypes.string,
  title: PropTypes.string,
  tab: PropTypes.number.isRequired,
  slug: PropTypes.string
}

HeadLayout.defaultProps = {
  imageUrl: null,
  imageWidth: null,
  imageHeight: null,
  imageMime: null,
  title: null,
  slug: null
}
