Skip to content

Commit

Permalink
docs: Update docs scripts (#5181)
Browse files Browse the repository at this point in the history
* docs: Update docs scripts

* update

* fix noscript
  • Loading branch information
zjy365 authored Oct 31, 2024
1 parent 2ca25f5 commit 0fe154f
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 64 deletions.
153 changes: 122 additions & 31 deletions docs/website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,32 @@ const config = {

themeConfig: { // @type {import('@docusaurus/preset-classic').ThemeConfig}
metadata: [{ name: 'title', content: 'Sealos by 环界云' }],
// announcementBar: {
// id: 'sealos_tip',
// content: `
// <div class="sealos-banner-box">
// <div>${isDomesticSite ? 'If you are an international user, please visit 👉' : '如果您是国内用户,请直接访问 👉 '}</div>
// <div class="sealos-banner-btn" onclick="window.open('${isDomesticSite ? 'https://sealos.io' : 'https://sealos.run'}', '_blank');">
// ${isDomesticSite ? 'International Site' : '国内官网'}
// </div>
// <svg
// onclick="handleBannerClose()"
// width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
// <g clip-path="url(#clip0_1145_366)">
// <path d="M12 22C6.477 22 2 17.523 2 12C2 6.477 6.477 2 12 2C17.523 2 22 6.477 22 12C22 17.523 17.523 22 12 22Z" fill="white" fill-opacity="0.16"/>
// <path d="M12 21.75C6.61507 21.75 2.25 17.3849 2.25 12C2.25 6.61507 6.61507 2.25 12 2.25C17.3849 2.25 21.75 6.61507 21.75 12C21.75 17.3849 17.3849 21.75 12 21.75Z" stroke="white" stroke-opacity="0.1" stroke-width="0.5"/>
// <path d="M9.17184 7.75696L11.9998 10.586L14.8278 7.75696L16.2428 9.17196L13.4138 12L16.2428 14.828L14.8278 16.243L11.9998 13.414L9.17184 16.243L7.75684 14.828L10.5858 12L7.75684 9.17196L9.17184 7.75696Z" fill="white"/>
// </g>
// <defs>
// <clipPath id="clip0_1145_366">
// <rect width="24" height="24" fill="white"/>
// </clipPath>
// </defs>
// </svg>
// </div>
// `,
// isCloseable: true,
// },
announcementBar: {
id: 'sealos_tip',
content: `
<div class="sealos-banner-box">
<div>${isDomesticSite ? 'If you are an international user, please visit 👉' : '如果您是国内用户,请直接访问 👉 '}</div>
<div class="sealos-banner-btn" onclick="window.open('${isDomesticSite ? 'https://sealos.io' : 'https://sealos.run'}', '_blank');">
${isDomesticSite ? 'International Site' : '国内官网'}
</div>
<svg
onclick="handleBannerClose()"
width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_1145_366)">
<path d="M12 22C6.477 22 2 17.523 2 12C2 6.477 6.477 2 12 2C17.523 2 22 6.477 22 12C22 17.523 17.523 22 12 22Z" fill="white" fill-opacity="0.16"/>
<path d="M12 21.75C6.61507 21.75 2.25 17.3849 2.25 12C2.25 6.61507 6.61507 2.25 12 2.25C17.3849 2.25 21.75 6.61507 21.75 12C21.75 17.3849 17.3849 21.75 12 21.75Z" stroke="white" stroke-opacity="0.1" stroke-width="0.5"/>
<path d="M9.17184 7.75696L11.9998 10.586L14.8278 7.75696L16.2428 9.17196L13.4138 12L16.2428 14.828L14.8278 16.243L11.9998 13.414L9.17184 16.243L7.75684 14.828L10.5858 12L7.75684 9.17196L9.17184 7.75696Z" fill="white"/>
</g>
<defs>
<clipPath id="clip0_1145_366">
<rect width="24" height="24" fill="white"/>
</clipPath>
</defs>
</svg>
</div>
`,
isCloseable: true,
},
algolia: {
// Algolia 提供的应用 ID
appId: "SLTSB7B9Y0",
Expand Down Expand Up @@ -251,11 +251,7 @@ const config = {
{
src: "/global.js",
async: true
},
...(isDomesticSite ? [{
src: 'https://hm.baidu.com/hm.js?d8e8ecf669c47dc2512d3f1417e761f9',
async: true,
}] : [])
}
],
headTags: [
{
Expand All @@ -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('<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5953N4CP" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>');
}
`,
},
]
}
},
}
},
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);
}
})();
`,
},
],
}
},
}
}
]
}

Expand Down
33 changes: 0 additions & 33 deletions docs/website/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<string, string> = {};
Expand Down Expand Up @@ -83,18 +62,6 @@ const Home = () => {
}
/>
</Head>
<Helmet>
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-786053845" />
<script async>
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-786053845');
gtag('event', 'conversion', {'send_to': 'AW-786053845/LpbTCJ-8-coYENX16PYC'});
`}
</script>
</Helmet>
<Layout>
<div className="home">
{/* <SaleBanner /> */}
Expand Down

0 comments on commit 0fe154f

Please sign in to comment.