Head.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React from 'react';
  2. import NextHead from 'next/head';
  3. import { withTranslation } from '../i18n';
  4. const defaultOGURL = '';
  5. const defaultOGImage = '';
  6. type Props = {
  7. t: (key: string) => string;
  8. title?: string;
  9. description?: string;
  10. url?: string;
  11. ogImage?: string;
  12. };
  13. const Head: React.StatelessComponent<Props> = ({
  14. t,
  15. title = 'title',
  16. description = 'description',
  17. url = '',
  18. ogImage = '',
  19. }: Props) => (
  20. <NextHead>
  21. <meta charSet="UTF-8" />
  22. <title>{t(title)}</title>
  23. <meta
  24. name="description"
  25. content={t(description)}
  26. />
  27. <meta name="viewport" content="width=device-width, initial-scale=1" />
  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
  35. property="og:description"
  36. content={t(description)}
  37. />
  38. <meta name="twitter:site" content={url || defaultOGURL} />
  39. <meta name="twitter:card" content="summary_large_image" />
  40. <meta name="twitter:image" content={ogImage || defaultOGImage} />
  41. <meta property="og:image" content={ogImage || defaultOGImage} />
  42. <meta property="og:image:width" content="1200" />
  43. <meta property="og:image:height" content="630" />
  44. <meta httpEquiv="X-UA-Compatible" content="IE=EmulateIE11,chrome=1" />
  45. </NextHead>
  46. );
  47. export default withTranslation('meta')(Head);