Skip to content

Commit

Permalink
feat:docs add link proxy
Browse files Browse the repository at this point in the history
Signed-off-by: jingyang <3161362058@qq.com>
  • Loading branch information
zjy365 committed Nov 7, 2023
1 parent ce5966d commit d3aa944
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# Misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
14 changes: 13 additions & 1 deletion docs/website/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
const generateAlgoliKey = () => "ce5b8e1e4d0d35ff587caf75ac404df4"
require('dotenv').config()

/** @type {import('@docusaurus/types').Config} */
const config = {
Expand All @@ -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.
Expand Down Expand Up @@ -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: [
Expand All @@ -207,6 +212,13 @@ const config = {
name: 'baidu-site-verification',
content: 'codeva-gAHDaifnOq',
},
},
{
tagName: 'meta',
attributes: {
name: 'baidu-site-verification',
content: 'codeva-E1X5UKtV9p',
},
}
],
plugins: [
Expand Down
9 changes: 5 additions & 4 deletions docs/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -52,4 +53,4 @@
"last 1 safari version"
]
}
}
}
6 changes: 4 additions & 2 deletions docs/website/src/hooks/useUploadData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }))
};

Expand Down
8 changes: 1 addition & 7 deletions docs/website/src/hooks/useWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions docs/website/src/pages/components/Header/index.phone.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
border-radius: 4px;
background: rgba(255, 255, 255, 0.2);
filter: blur(4px);
pointer-events: none;
}

.start-now-button {
Expand Down
1 change: 1 addition & 0 deletions docs/website/src/pages/components/Header/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
border-radius: 4px;
background: rgba(255, 255, 255, 0.2);
filter: blur(4px);
pointer-events: none;
}

.start-now-button {
Expand Down
2 changes: 1 addition & 1 deletion docs/website/src/pages/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
console.log('uploadConvertData');
uploadConvertData([
{
newType: 51
newType: 1
}
]);
}
Expand Down
2 changes: 0 additions & 2 deletions docs/website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ const Home = () => {
gtag('event', 'conversion', {'send_to': 'AW-786053845/LpbTCJ-8-coYENX16PYC'});
`}
</script>
<meta name="baidu-site-verification" content="codeva-gAHDaifnOq" />
{/* <script src="./linkInterception.js"></script> */}
</Helmet>
<Layout>
<div className="home">
Expand Down
2 changes: 2 additions & 0 deletions docs/website/src/pages/self-hosting/header/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
border-radius: 4px;
background: rgba(255, 255, 255, 0.2);
filter: blur(4px);
pointer-events: none;
}

.start-now-button {
Expand Down Expand Up @@ -242,6 +243,7 @@
border-radius: 4px;
background: rgba(255, 255, 255, 0.2);
filter: blur(4px);
pointer-events: none;
}

.start-now-button {
Expand Down
23 changes: 23 additions & 0 deletions docs/website/static/global.js
Original file line number Diff line number Diff line change
@@ -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)
}
}
})
})
5 changes: 5 additions & 0 deletions docs/website/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d3aa944

Please sign in to comment.