Skip to content

Commit

Permalink
fix:docs add head meta
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 98dbeb4 commit 1a1cfd8
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
13 changes: 12 additions & 1 deletion docs/website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const config = {
onBrokenLinks: "warn",
onBrokenMarkdownLinks: "warn",
favicon: "img/favicon.ico",

customFields: {
bdToken: process.env.BD_TOKEN,
},
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: "labring", // Usually your GitHub org/user name.
Expand Down Expand Up @@ -198,6 +200,15 @@ const config = {
async: false,
}
],
headTags: [
{
tagName: 'meta',
attributes: {
name: 'baidu-site-verification',
content: 'codeva-gAHDaifnOq',
},
}
],
plugins: [
'docusaurus-plugin-sass',
async function myPlugin (context, options) {
Expand Down
42 changes: 42 additions & 0 deletions docs/website/src/hooks/useUploadData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import { useEffect, useState } from 'react';
import useIsBrowser from '@docusaurus/useIsBrowser';

export default function useUploadData() {
const isBrowser = useIsBrowser();
const [id, setId] = useState('');
const {
siteConfig: { customFields }
} = useDocusaurusContext();

useEffect(() => {
if (!isBrowser) return;
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;
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,
conversionTypes: params.map((newType) => ({ logidUrl: logidUrl, newType: newType }))
};

return fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
}

return {
id,
uploadConvertData
};
}
17 changes: 16 additions & 1 deletion docs/website/src/pages/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import LogoIcon from '@site/static/icons/sealos.svg';
import React, { useEffect, useState } from 'react';
import VideoPlayer from '../VideoPlayer';
import './index.scss';
import useUploadData from '@site/src/hooks/useUploadData';

const navbar = [
{
Expand Down Expand Up @@ -42,6 +43,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
const [stars, setStars] = useState(10000);
const isBrowser = useIsBrowser();
const { cloudUrl } = useWindow();
const { uploadConvertData } = useUploadData();

const i18nMap: { [key: string]: { label: string; link: string } } = {
en: { label: '中', link: '/zh-Hans/' },
Expand Down Expand Up @@ -164,7 +166,20 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
</div>
<div className="links">
{navbar.map((item) => (
<Link key={item.key} to={item.to}>
<Link
key={item.key}
to={item.to}
onClick={() => {
if (item.key === 'contact') {
console.log('uploadConvertData');
uploadConvertData([
{
newType: 51
}
]);
}
}}
>
{item.label}
</Link>
))}
Expand Down
7 changes: 7 additions & 0 deletions docs/website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ const Home = () => {
loadUmamiScript();
}, []);

useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
const bd_vidValue = urlParams.get('bd_vid');
sessionStorage.setItem('bd_vid', bd_vidValue);
}, []);

const HomeRender = (
<div id="sealos-layout-wrap-home-page">
<Banner />
Expand All @@ -52,6 +58,7 @@ const Home = () => {
`}
</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/product/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';

export default function Product() {
const standard = ['工单服务', '应用管理', '高可用数据库', '应用市场', '多租户', '计量/配额'];

const company = [
'工单/即时通信服务',
'周一到周五, 8h 内响应',
Expand All @@ -13,6 +14,7 @@ export default function Product() {
'多租户',
'计量/配额'
];

const contact = [
'定制化开发与业务云原生化服务',
'超大规模集群',
Expand Down

0 comments on commit 1a1cfd8

Please sign in to comment.