diff --git a/docs/website/.gitignore b/docs/website/.gitignore index 1ee8fd85f5f..e83755844c1 100644 --- a/docs/website/.gitignore +++ b/docs/website/.gitignore @@ -10,6 +10,7 @@ # Misc .DS_Store +.env .env.local .env.development.local .env.test.local diff --git a/docs/website/docusaurus.config.js b/docs/website/docusaurus.config.js index 7bcc4e62505..e3ea1c625c0 100644 --- a/docs/website/docusaurus.config.js +++ b/docs/website/docusaurus.config.js @@ -1,5 +1,6 @@ // @ts-check const generateAlgoliKey = () => "ce5b8e1e4d0d35ff587caf75ac404df4" +require('dotenv').config() /** @type {import('@docusaurus/types').Config} */ const config = { @@ -11,7 +12,7 @@ const config = { onBrokenMarkdownLinks: "warn", favicon: "img/favicon.ico", customFields: { - bdToken: process.env.BD_TOKEN, + BD_TOKEN: process.env.BD_TOKEN, }, // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these. @@ -198,6 +199,10 @@ const config = { { src: "https://cdn.bootcdn.net/ajax/libs/wow/1.1.2/wow.min.js", async: false, + }, + { + src: "/global.js", + async: true, } ], headTags: [ @@ -207,6 +212,13 @@ const config = { name: 'baidu-site-verification', content: 'codeva-gAHDaifnOq', }, + }, + { + tagName: 'meta', + attributes: { + name: 'baidu-site-verification', + content: 'codeva-E1X5UKtV9p', + }, } ], plugins: [ diff --git a/docs/website/package.json b/docs/website/package.json index 0d9caa7a1b2..14812c1413b 100644 --- a/docs/website/package.json +++ b/docs/website/package.json @@ -20,18 +20,19 @@ "@docusaurus/core": "^2.4.3", "@docusaurus/preset-classic": "^2.4.3", "@docusaurus/theme-search-algolia": "^2.4.3", + "@headlessui/react": "^1.7.17", "@mdx-js/react": "^1.6.22", + "autoprefixer": "^10.4.16", "docusaurus-plugin-sass": "^0.2.2", + "dotenv": "^16.3.1", + "postcss": "^8.4.31", "prism-react-renderer": "^1.3.5", "prismjs": "^1.29.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-helmet": "^6.1.0", "sass": "^1.62.1", - "@headlessui/react": "^1.7.17", - "autoprefixer": "^10.4.16", "tailwindcss": "^3.3.3", - "postcss": "^8.4.31", "wowjs": "^1.1.3" }, "devDependencies": { @@ -52,4 +53,4 @@ "last 1 safari version" ] } -} \ No newline at end of file +} diff --git a/docs/website/src/hooks/useUploadData.ts b/docs/website/src/hooks/useUploadData.ts index 1d4239f7a2a..a1a0857803e 100644 --- a/docs/website/src/hooks/useUploadData.ts +++ b/docs/website/src/hooks/useUploadData.ts @@ -11,18 +11,20 @@ export default function useUploadData() { useEffect(() => { if (!isBrowser) return; + console.log(customFields); let bd_vid = sessionStorage.getItem('bd_vid'); if (bd_vid) setId(bd_vid); }, [isBrowser]); async function uploadConvertData(params: { newType: number }[]) { - if (!isBrowser || !customFields?.bdToken || !id) return; + if (!isBrowser || !customFields?.BD_TOKEN || !id) return; const url = 'https://ocpc.baidu.com/ocpcapi/api/uploadConvertData'; const logidUrl = `${window.location.origin}?bd_vid=${id}`; + console.log(customFields, id, '========', logidUrl); const data = { - token: customFields.bdToken, + token: customFields?.BD_TOKEN, conversionTypes: params.map((newType) => ({ logidUrl: logidUrl, newType: newType })) }; diff --git a/docs/website/src/hooks/useWindow.ts b/docs/website/src/hooks/useWindow.ts index f2fe0e0fc1c..ac3eb1031c7 100644 --- a/docs/website/src/hooks/useWindow.ts +++ b/docs/website/src/hooks/useWindow.ts @@ -16,14 +16,8 @@ export default function () { requestAnimationFrame(() => setScreenWidth(document?.body.clientWidth)); }; window.addEventListener('resize', updateScreenWidth); - // handle - setCurrentLanguage(document.documentElement.lang); - // console.log(document.documentElement.lang, window.location, navigator.language); - // if (navigator.language !== 'en' && !window.location.pathname.includes('zh-Hans')) { - // const newPath = window.location.pathname.endsWith('/') ? 'zh-Hans/' : '/zh-Hans/'; - // window.location.pathname += newPath; - // } + setCurrentLanguage(document.documentElement.lang); setCloudUrl( document.documentElement.lang === 'en' diff --git a/docs/website/src/pages/components/Header/index.phone.scss b/docs/website/src/pages/components/Header/index.phone.scss index 5efb90939a4..1649bbf592f 100644 --- a/docs/website/src/pages/components/Header/index.phone.scss +++ b/docs/website/src/pages/components/Header/index.phone.scss @@ -54,6 +54,7 @@ border-radius: 4px; background: rgba(255, 255, 255, 0.2); filter: blur(4px); + pointer-events: none; } .start-now-button { diff --git a/docs/website/src/pages/components/Header/index.scss b/docs/website/src/pages/components/Header/index.scss index ff85ddc2b10..e7625619b1a 100644 --- a/docs/website/src/pages/components/Header/index.scss +++ b/docs/website/src/pages/components/Header/index.scss @@ -109,6 +109,7 @@ border-radius: 4px; background: rgba(255, 255, 255, 0.2); filter: blur(4px); + pointer-events: none; } .start-now-button { diff --git a/docs/website/src/pages/components/Header/index.tsx b/docs/website/src/pages/components/Header/index.tsx index d1e77f2aa30..42ce2c45dd8 100644 --- a/docs/website/src/pages/components/Header/index.tsx +++ b/docs/website/src/pages/components/Header/index.tsx @@ -174,7 +174,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => { console.log('uploadConvertData'); uploadConvertData([ { - newType: 51 + newType: 1 } ]); } diff --git a/docs/website/src/pages/index.tsx b/docs/website/src/pages/index.tsx index 418372d6f77..f0c129fb96b 100644 --- a/docs/website/src/pages/index.tsx +++ b/docs/website/src/pages/index.tsx @@ -57,8 +57,6 @@ const Home = () => { gtag('event', 'conversion', {'send_to': 'AW-786053845/LpbTCJ-8-coYENX16PYC'}); `} - - {/* */}
diff --git a/docs/website/src/pages/self-hosting/header/index.scss b/docs/website/src/pages/self-hosting/header/index.scss index 1f9c0bd3df2..bc57055a263 100644 --- a/docs/website/src/pages/self-hosting/header/index.scss +++ b/docs/website/src/pages/self-hosting/header/index.scss @@ -105,6 +105,7 @@ border-radius: 4px; background: rgba(255, 255, 255, 0.2); filter: blur(4px); + pointer-events: none; } .start-now-button { @@ -242,6 +243,7 @@ border-radius: 4px; background: rgba(255, 255, 255, 0.2); filter: blur(4px); + pointer-events: none; } .start-now-button { diff --git a/docs/website/static/global.js b/docs/website/static/global.js new file mode 100644 index 00000000000..3e82eb733fa --- /dev/null +++ b/docs/website/static/global.js @@ -0,0 +1,23 @@ +document.addEventListener("DOMContentLoaded", function () { + console.log('addEventListener') + const parentElement = document.body + parentElement.addEventListener("click", function (event) { + if (event.target.tagName === "A") { + const href = event.target.getAttribute("href") + const currentHostname = window.location.hostname + const bdId = sessionStorage.getItem("bd_vid") + console.log(bdId) + if (href.includes("sealos.io") || href.includes("sealos.top") || href.includes("sealos.run")) { + event.preventDefault() + console.log("特殊处理链接: " + href) + + const targetHostname = (currentHostname === "sealos.io") ? "sealos.io" : "sealos.top" + const modifiedHref = href.replace("sealos.io", targetHostname) + console.log(modifiedHref, '修改后的链接') + + event.target.href = modifiedHref + window.open(modifiedHref) + } + } + }) +}) diff --git a/docs/website/yarn.lock b/docs/website/yarn.lock index 7d3088d3bae..0d5f203176f 100644 --- a/docs/website/yarn.lock +++ b/docs/website/yarn.lock @@ -3661,6 +3661,11 @@ dot-prop@^5.2.0: dependencies: is-obj "^2.0.0" +dotenv@^16.3.1: + version "16.3.1" + resolved "https://registry.npmmirror.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e" + integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ== + duplexer3@^0.1.4: version "0.1.5" resolved "https://registry.npmjs.org/duplexer3/-/duplexer3-0.1.5.tgz"