next-app-boilerplate/components/NextHead.tsx

65 lines
2.3 KiB
TypeScript
Raw Normal View History

2022-05-16 14:25:22 +02:00
import Head from 'next/head'
2023-02-10 13:18:30 +01:00
import type { SEODefaultValues } from 'types/config'
2023-02-10 12:42:05 +01:00
import { SEOConfig } from 'utils/config'
2022-05-16 14:25:22 +02:00
2023-02-10 12:42:05 +01:00
const NextHead: React.FC<SEODefaultValues> = ({
shortName = SEOConfig.shortName,
longName = SEOConfig.longName,
color = SEOConfig.color,
defaultLocale = SEOConfig.defaultLocale,
description = SEOConfig.description,
icons = SEOConfig.icons,
url = SEOConfig.url
}) => {
return (
<Head>
2023-02-10 12:42:05 +01:00
<title>{shortName}</title>
2023-02-10 12:42:05 +01:00
<link rel='shortcut icon' href={icons?.default} type='image/x-icon' />
<link rel='apple-touch-icon' sizes='180x180' href={icons?.apple} />
<link rel='icon' type='image/png' sizes='16x16' href={icons?.['16_16']} />
<link rel='icon' type='image/png' sizes='32x32' href={icons?.['32_32']} />
{/* Default meta tags */}
2023-02-10 12:42:05 +01:00
<meta charSet='UTF-8' />
<meta httpEquiv='X-UA-Compatible' content='IE=edge' />
2022-05-16 14:25:22 +02:00
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
2023-02-10 12:42:05 +01:00
<meta name='description' content={description} />
<meta name='language' content={defaultLocale} />
<meta name='theme-color' content={color} />
<meta name='copyright' content={shortName} />
<meta name='author' content={shortName} />
<meta name='publisher' content={shortName} />
<meta name='robots' content='index, follow' />
<meta name='rating' content='general' />
<meta name='distribution' content='global' />
2023-02-10 12:42:05 +01:00
<meta name='msapplication-TileColor' content={color} />
{/* Open graph MT */}
2023-02-10 12:42:05 +01:00
<meta property='og:title' content={shortName} />
<meta property='og:type' content='website' />
2023-02-10 12:42:05 +01:00
<meta property='og:url' content={url} />
<meta property='og:image' content={icons?.image} />
<meta property='og:description' content={description} />
2022-05-16 14:25:22 +02:00
<meta
property='og:locale'
2023-02-10 12:42:05 +01:00
content={SEOConfig.defaultLocale?.concat(
'_',
SEOConfig.defaultLocale.toUpperCase()
)}
2022-05-16 14:25:22 +02:00
/>
2023-02-10 12:42:05 +01:00
<meta property='og:site_name' content={longName} />
{/* Twitter card Metadata */}
<meta name='twitter:card' content='summary' />
2023-02-10 12:42:05 +01:00
<meta name='twitter:description' content={description} />
<meta name='twitter:title' content={longName} />
<meta name='twitter:image:src' content={icons?.image} />
</Head>
)
}
2022-05-16 14:25:22 +02:00
export default NextHead