_document.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* eslint-disable react/no-danger */
  2. import React from 'react';
  3. import Document, { Head, Main, NextScript } from 'next/document';
  4. import { ServerStyleSheet } from 'styled-components';
  5. const style = {
  6. margin: 0,
  7. backgroundColor: '#f3f3f3',
  8. font: '16px/1.45 "Nunito", sans-serif',
  9. overflowX: 'hidden',
  10. color: 'black',
  11. };
  12. class AppDocument extends Document {
  13. static getInitialProps({ renderPage }) {
  14. const sheet = new ServerStyleSheet();
  15. const page = renderPage(App => props => sheet.collectStyles(<App {...props} />));
  16. const styleTags = sheet.getStyleElement();
  17. return { ...page, styleTags };
  18. }
  19. render() {
  20. return (
  21. <html lang="en">
  22. <Head>
  23. <meta charSet="utf-8" />
  24. <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
  25. <meta
  26. name="description"
  27. content="Kutt.it is a free and open source URL shortener with custom domains and stats."
  28. />
  29. <link
  30. href="https://fonts.googleapis.com/css?family=Nunito:300,400,700"
  31. rel="stylesheet"
  32. />
  33. <link rel="icon" sizes="196x196" href="/images/favicon-196x196.png" />
  34. <link rel="icon" sizes="32x32" href="/images/favicon-32x32.png" />
  35. <link rel="icon" sizes="16x16" href="/images/favicon-16x16.png" />
  36. <link rel="apple-touch-icon" href="/images/favicon-196x196.png" />
  37. <link rel="mask-icon" href="/images/icon.svg" color="blue" />
  38. <link rel="manifest" href="manifest.webmanifest" />
  39. <meta name="theme-color" content="#f3f3f3" />
  40. <meta property="fb:app_id" content="123456789" />
  41. <meta property="og:url" content="https://kutt.it" />
  42. <meta property="og:type" content="website" />
  43. <meta property="og:title" content="Kutt.it" />
  44. <meta property="og:image" content="https://kutt.it/images/card.png" />
  45. <meta property="og:description" content="Free & Open Source Modern URL Shortener" />
  46. <meta name="twitter:url" content="https://kutt.it" />
  47. <meta name="twitter:title" content="Kutt.it" />
  48. <meta name="twitter:description" content="Free & Open Source Modern URL Shortener" />
  49. <meta name="twitter:image" content="https://kutt.it/images/card.png" />
  50. {this.props.styleTags}
  51. <script
  52. dangerouslySetInnerHTML={{
  53. __html: `window.recaptchaCallback = function() { window.isCaptchaReady = true; }`,
  54. }}
  55. />
  56. <script
  57. dangerouslySetInnerHTML={{
  58. __html: `
  59. if('serviceWorker' in navigator) {
  60. navigator.serviceWorker.register('sw.js', {
  61. scope: './'
  62. })
  63. }
  64. `,
  65. }}
  66. />
  67. <script src="https://www.google.com/recaptcha/api.js?render=explicit" async defer />
  68. <script src="/analytics.js" />
  69. </Head>
  70. <body style={style}>
  71. <Main />
  72. <NextScript />
  73. </body>
  74. </html>
  75. );
  76. }
  77. }
  78. export default AppDocument;