Head.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React from 'react';
  2. import NextHead from 'next/head';
  3. import { useTranslation } from 'react-i18next';
  4. const defaultOGURL = '';
  5. const defaultOGImage = '';
  6. type Props = {
  7. title?: string;
  8. description?: string;
  9. url?: string;
  10. ogImage?: string;
  11. };
  12. const Head: React.SFC<Props> = ({
  13. title = 'title',
  14. description = 'description',
  15. url = '',
  16. ogImage = '',
  17. }: Props) => {
  18. const { t } = useTranslation('meta');
  19. return (
  20. <NextHead>
  21. <meta charSet="UTF-8" />
  22. <title>{t(title)}</title>
  23. <meta name="description" content={t(description)} />
  24. <meta
  25. name="viewport"
  26. content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=NO"
  27. />
  28. <link rel="icon" sizes="192x192" href="/static/touch-icon.png" />
  29. <link rel="apple-touch-icon" href="/static/touch-icon.png" />
  30. <link rel="mask-icon" href="/static/favicon-mask.svg" color="#49B882" />
  31. <link rel="icon" href="/static/favicon.ico" />
  32. <meta property="og:url" content={url || defaultOGURL} />
  33. <meta property="og:title" content={title || ''} />
  34. <meta property="og:description" content={t(description)} />
  35. <meta name="twitter:site" content={url || defaultOGURL} />
  36. <meta name="twitter:card" content="summary_large_image" />
  37. <meta name="twitter:image" content={ogImage || defaultOGImage} />
  38. <meta property="og:image" content={ogImage || defaultOGImage} />
  39. <meta property="og:image:width" content="1200" />
  40. <meta property="og:image:height" content="630" />
  41. <meta httpEquiv="X-UA-Compatible" content="IE=EmulateIE11,chrome=1" />
  42. </NextHead>
  43. );
  44. };
  45. export default Head;