Head.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import NextHead from 'next/head';
  4. import { withTranslation } from '../i18n';
  5. const defaultOGURL = '';
  6. const defaultOGImage = '';
  7. const Head = ({
  8. t,
  9. title,
  10. description,
  11. url,
  12. ogImage,
  13. }) => (
  14. <NextHead>
  15. <meta charSet="UTF-8" />
  16. <title>{t(title)}</title>
  17. <meta
  18. name="description"
  19. content={t(description)}
  20. />
  21. <meta name="viewport" content="width=device-width, initial-scale=1" />
  22. <link rel="icon" sizes="192x192" href="/static/touch-icon.png" />
  23. <link rel="apple-touch-icon" href="/static/touch-icon.png" />
  24. <link rel="mask-icon" href="/static/favicon-mask.svg" color="#49B882" />
  25. <link rel="icon" href="/static/favicon.ico" />
  26. <meta property="og:url" content={url || defaultOGURL} />
  27. <meta property="og:title" content={title || ''} />
  28. <meta
  29. property="og:description"
  30. content={t(description)}
  31. />
  32. <meta name="twitter:site" content={url || defaultOGURL} />
  33. <meta name="twitter:card" content="summary_large_image" />
  34. <meta name="twitter:image" content={ogImage || defaultOGImage} />
  35. <meta property="og:image" content={ogImage || defaultOGImage} />
  36. <meta property="og:image:width" content="1200" />
  37. <meta property="og:image:height" content="630" />
  38. </NextHead>
  39. );
  40. Head.propTypes = {
  41. t: PropTypes.func.isRequired,
  42. title: PropTypes.string,
  43. description: PropTypes.string,
  44. url: PropTypes.string,
  45. ogImage: PropTypes.string,
  46. };
  47. Head.defaultProps = {
  48. title: 'title',
  49. description: 'description',
  50. url: '',
  51. ogImage: '',
  52. };
  53. export default withTranslation('meta')(Head);