head.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import fs from 'fs'
  2. import path from 'path'
  3. import { vpRoot } from '@element-plus/build-utils'
  4. import { languages } from '../utils/lang'
  5. import type { HeadConfig } from 'vitepress'
  6. export const head: HeadConfig[] = [
  7. [
  8. 'link',
  9. {
  10. rel: 'icon',
  11. href: '/images/element-plus-logo-small.svg',
  12. type: 'image/svg+xm',
  13. },
  14. ],
  15. [
  16. 'link',
  17. {
  18. rel: 'apple-touch-icon',
  19. href: '/apple-touch-icon.png',
  20. sizes: '180x180',
  21. },
  22. ],
  23. [
  24. 'link',
  25. {
  26. rel: 'mask-icon',
  27. href: '/safari-pinned-tab.svg',
  28. color: '#5bbad5',
  29. },
  30. ],
  31. [
  32. 'meta',
  33. {
  34. name: 'theme-color',
  35. content: '#ffffff',
  36. },
  37. ],
  38. [
  39. 'meta',
  40. {
  41. name: 'msapplication-TileColor',
  42. content: '#409eff',
  43. },
  44. ],
  45. [
  46. 'meta',
  47. {
  48. name: 'msapplication-config',
  49. content: '/browserconfig.xml',
  50. },
  51. ],
  52. [
  53. 'script',
  54. {},
  55. `;(() => {
  56. window.supportedLangs = ${JSON.stringify(languages)}
  57. })()`,
  58. ],
  59. ['script', {}, fs.readFileSync(path.resolve(vpRoot, 'lang.js'), 'utf-8')],
  60. // [
  61. // 'script',
  62. // {
  63. // async: 'true',
  64. // src: 'https://www.googletagmanager.com/gtag/js?id=UA-175337989-1',
  65. // },
  66. // ],
  67. [
  68. 'script',
  69. {},
  70. `if ('serviceWorker' in navigator) {
  71. navigator.serviceWorker
  72. .register('/sw.js')
  73. .then(function(registration) {
  74. console.log(registration);
  75. })
  76. .catch(function(err) {
  77. console.log(err);
  78. });
  79. }`,
  80. ],
  81. // [
  82. // 'script',
  83. // {
  84. // async: 'true',
  85. // },
  86. // `window.dataLayer = window.dataLayer || [];
  87. // function gtag(){dataLayer.push(arguments);}
  88. // gtag('js', new Date());
  89. // gtag('config', 'UA-175337989-1');`,
  90. // ],
  91. // [
  92. // 'script',
  93. // {
  94. // async: 'true',
  95. // src: 'https://www.googletagmanager.com/gtag/js?id=G-M74ZHEQ1M1',
  96. // },
  97. // ],
  98. // [
  99. // 'script',
  100. // {},
  101. // `
  102. // window.dataLayer = window.dataLayer || [];
  103. // function gtag(){dataLayer.push(arguments);}
  104. // gtag('js', new Date());
  105. // gtag('config', 'G-M74ZHEQ1M1');
  106. // `,
  107. // ],
  108. // [
  109. // 'script',
  110. // {},
  111. // `(function(h,o,t,j,a,r){
  112. // h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
  113. // h._hjSettings={hjid:2894908,hjsv:6};
  114. // a=o.getElementsByTagName('head')[0];
  115. // r=o.createElement('script');r.async=1;
  116. // r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
  117. // a.appendChild(r);
  118. // })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');`,
  119. // ],
  120. [
  121. 'script',
  122. {
  123. async: 'true',
  124. },
  125. `
  126. var resource = document.createElement('link');
  127. resource.setAttribute("rel", "stylesheet");
  128. resource.setAttribute("href","//fonts.loli.net/css?family=Inter:300,400,500,600|Open+Sans:400,600;display=swap");
  129. resource.setAttribute("type","text/css");
  130. var head = document.querySelector('head');
  131. head.appendChild(resource);
  132. `,
  133. ],
  134. ]
  135. head.push(['script', {}, fs.readFileSync(path.resolve(vpRoot, 'dark-mode.js'), 'utf-8')])