diff --git a/docs/website/docusaurus.config.js b/docs/website/docusaurus.config.js index eccc6c41755..8ba2a26c79c 100644 --- a/docs/website/docusaurus.config.js +++ b/docs/website/docusaurus.config.js @@ -75,32 +75,32 @@ const config = { themeConfig: { // @type {import('@docusaurus/preset-classic').ThemeConfig} metadata: [{ name: 'title', content: 'Sealos by 环界云' }], - // announcementBar: { - // id: 'sealos_tip', - // content: ` - //
- // `, - // isCloseable: true, - // }, + announcementBar: { + id: 'sealos_tip', + content: ` + + `, + isCloseable: true, + }, algolia: { // Algolia 提供的应用 ID appId: "SLTSB7B9Y0", @@ -251,11 +251,7 @@ const config = { { src: "/global.js", async: true - }, - ...(isDomesticSite ? [{ - src: 'https://hm.baidu.com/hm.js?d8e8ecf669c47dc2512d3f1417e761f9', - async: true, - }] : []) + } ], headTags: [ { @@ -279,6 +275,101 @@ const config = { }, } }, + function gtmPlugin (context, options) { + return { + name: 'docusaurus-gtm-plugin', + injectHtmlTags () { + return { + headTags: [ + { + tagName: 'script', + innerHTML: ` + (function() { + const hostname = window.location.hostname; + if (hostname !== 'sealos.run') { + (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': + new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], + j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= + 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); + })(window,document,'script','dataLayer','GTM-5953N4CP'); + } + })(); + `, + }, + ], + preBodyTags: [ + { + tagName: 'script', + innerHTML: ` + if (window.location.hostname !== 'sealos.run') { + document.write(''); + } + `, + }, + ] + } + }, + } + }, + function umamiPlugin (context, options) { + return { + name: 'docusaurus-umami-plugin', + injectHtmlTags () { + return { + headTags: [ + { + tagName: 'script', + innerHTML: ` + (function() { + const hostname = window.location.hostname; + if (hostname === 'sealos.run') { + const script1 = document.createElement('script'); + script1.src = 'https://umami.cloud.sealos.io/oishii'; + script1.setAttribute('data-website-id', 'e5a8009f-7cb6-4841-9522-d23b96216b7a'); + script1.async = true; + document.head.appendChild(script1); + } else { + const script2 = document.createElement('script'); + script2.src = 'https://umami.cloud.sealos.io/oishii'; + script2.setAttribute('data-website-id', 'a1c29ace-b288-431a-a2eb-8617d1d5b5ed'); + script2.async = true; + document.head.appendChild(script2); + } + })(); + `, + }, + ], + } + }, + } + }, + function baiduPlugin (context, options) { + return { + name: 'docusaurus-baidu-plugin', + injectHtmlTags () { + return { + headTags: [ + { + tagName: 'script', + innerHTML: ` + (function() { + const hostname = window.location.hostname; + if (hostname === 'sealos.run') { + var _hmt = _hmt || []; + var hm = document.createElement("script"); + hm.src = "https://hm.baidu.com/hm.js?d8e8ecf669c47dc2512d3f1417e761f9"; + hm.async = true; + var s = document.getElementsByTagName("script")[0]; + s.parentNode.insertBefore(hm, s); + } + })(); + `, + }, + ], + } + }, + } + } ] } diff --git a/docs/website/src/pages/index.tsx b/docs/website/src/pages/index.tsx index 88c4eac6dc6..519f0a6cfe6 100644 --- a/docs/website/src/pages/index.tsx +++ b/docs/website/src/pages/index.tsx @@ -1,7 +1,6 @@ import '@site/src/css/animate.css'; import Layout from '@theme/Layout'; import React, { useEffect, useMemo } from 'react'; -import { Helmet } from 'react-helmet'; import { PC_MIN_WIDTH } from '../constants/platform'; import useWindow from '../hooks/useWindow'; import Capability from './components/Capability'; @@ -20,26 +19,6 @@ const Home = () => { const isPc = useMemo(() => screenWidth > PC_MIN_WIDTH, [screenWidth]); const { i18n } = useDocusaurusContext(); - useEffect(() => { - const loadUmamiScript = () => { - const hostname = window.location.hostname; - if (hostname === 'sealos.run') { - const script1 = document.createElement('script'); - script1.src = 'https://umami.cloud.sealos.io/oishii'; - script1.setAttribute('data-website-id', 'e5a8009f-7cb6-4841-9522-d23b96216b7a'); - script1.async = true; - document.head.appendChild(script1); - } else { - const script2 = document.createElement('script'); - script2.src = 'https://umami.cloud.sealos.io/oishii'; - script2.setAttribute('data-website-id', 'a1c29ace-b288-431a-a2eb-8617d1d5b5ed'); - script2.async = true; - document.head.appendChild(script2); - } - }; - loadUmamiScript(); - }, []); - useEffect(() => { const urlParams = new URLSearchParams(window.location.search); const params: Record