From a807ccc00e5d90fb78d2da999926c34e35efcb82 Mon Sep 17 00:00:00 2001 From: zjy <3161362058@qq.com> Date: Wed, 30 Oct 2024 14:45:33 +0800 Subject: [PATCH 1/3] docs: Update docs scripts --- docs/website/docusaurus.config.js | 147 +++++++++++++++++++++++------- docs/website/src/pages/index.tsx | 33 ------- 2 files changed, 116 insertions(+), 64 deletions(-) diff --git a/docs/website/docusaurus.config.js b/docs/website/docusaurus.config.js index eccc6c41755..c252aca1bfe 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,95 @@ const config = { }, } }, + function gtmPlugin (context, options) { + return { + name: 'docusaurus-gtm-plugin', + injectHtmlTags () { + return { + headTags: [ + { + tagName: 'script', + innerHTML: ` + (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: 'noscript', + innerHTML: ` + + `, + }, + ], + } + }, + } + }, + 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