Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docs): add SEM keywords parameter #4981

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions docs/website/src/hooks/useWindow.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import { useEffect, useState } from 'react';
import useIsBrowser from '@docusaurus/useIsBrowser';

interface SemParams {
bd_vid: string;
keywords: string;
}

export default function useWindow() {
const isBrowser = useIsBrowser();
const [screenWidth, setScreenWidth] = useState(isBrowser ? document.body.clientWidth : 1440);
const [currentLanguage, setCurrentLanguage] = useState(
isBrowser ? document.documentElement.lang : 'en'
);
const [cloudUrl, setCloudUrl] = useState('https://cloud.sealos.io');
const [bd_vid, setBdId] = useState('');
const [semParams, setSemParams] = useState<SemParams>({ bd_vid: '', keywords: '' });

useEffect(() => {
if (!isBrowser) return;
let bd_vid = sessionStorage.getItem('bd_vid');
if (bd_vid) setBdId(bd_vid);
const storedParams = sessionStorage.getItem('sealos_sem');
if (storedParams) {
const parsedParams = JSON.parse(storedParams);
setSemParams((prevParams) => ({ ...prevParams, ...parsedParams }));
}
}, [isBrowser]);

useEffect(() => {
Expand Down Expand Up @@ -41,6 +49,6 @@ export default function useWindow() {
screenWidth,
currentLanguage,
cloudUrl,
bd_vid
semParams
};
}
19 changes: 14 additions & 5 deletions docs/website/src/pages/components/Capability/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const i18nObj = {

const Capability = ({ isPc }: { isPc: boolean }) => {
const isBrowser = useIsBrowser();
const { screenWidth, currentLanguage, cloudUrl, bd_vid } = useWindow();
const { screenWidth, currentLanguage, cloudUrl, semParams } = useWindow();

useLayoutEffect(() => {
// @ts-ignore nextline
Expand Down Expand Up @@ -67,7 +67,7 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
<h3> {i18nObj.appMan} </h3>
<h4>{i18nObj.appManagement_introduce}</h4>
<a
href={`${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-applaunchpad%3F`}
href={`${cloudUrl}/?bd_vid=${semParams.bd_vid}&k=${semParams.keywords}&openapp=system-applaunchpad%3F`}
target="_black"
>
{i18nObj.Explore} {'>'}
Expand All @@ -87,7 +87,10 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
</div>
<div className="application-title">{i18nObj.database} </div>
<div className="application-text">{i18nObj.database_introduce}</div>
<a href={`${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-dbprovider%3F`} target="_black">
<a
href={`${cloudUrl}/?bd_vid=${semParams.bd_vid}&k=${semParams.keywords}&openapp=system-dbprovider%3F`}
target="_black"
>
{i18nObj.Explore} {'>'}
</a>
<img
Expand Down Expand Up @@ -128,7 +131,10 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
</div>
<h3> {i18nObj.appMan} </h3>
<h4>{i18nObj.appManagement_introduce}</h4>
<a href={`${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-applaunchpad%3F`} target="_black">
<a
href={`${cloudUrl}/?bd_vid=${semParams.bd_vid}&k=${semParams.keywords}&openapp=system-applaunchpad%3F`}
target="_black"
>
{i18nObj.Explore} {'>'}
</a>
</div>
Expand All @@ -146,7 +152,10 @@ const Capability = ({ isPc }: { isPc: boolean }) => {
</div>
<div className="application-title">{i18nObj.database}</div>
<div className="application-text">{i18nObj.database_introduce}</div>
<a href={`${cloudUrl}/?bd_vid=${bd_vid}&openapp=system-dbprovider%3F`} target="_black">
<a
href={`${cloudUrl}/?bd_vid=${semParams.bd_vid}&k=${semParams.keywords}&openapp=system-dbprovider%3F`}
target="_black"
>
{i18nObj.Explore} {'>'}
</a>
<img
Expand Down
14 changes: 11 additions & 3 deletions docs/website/src/pages/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const i18nObj = {
const HomeHeader = ({ isPc }: { isPc: boolean }) => {
const [stars, setStars] = useState(10000);
const isBrowser = useIsBrowser();
const { cloudUrl, bd_vid } = useWindow();
const { cloudUrl, semParams } = useWindow();

const {
i18n: { currentLocale, defaultLocale }
Expand Down Expand Up @@ -140,7 +140,11 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
部署、管理和扩展应用的云操作系统。就像使用个人电脑一样!
</h3>
)}
<a className="start-now-button" href={`${cloudUrl}?bd_vid=${bd_vid}`} target="_blank">
<a
className="start-now-button"
href={`${cloudUrl}?bd_vid=${semParams.bd_vid}&k=${semParams.keywords}`}
target="_blank"
>
{i18nObj.startNow}
<div className="start-now-button-wrap"></div>
</a>
Expand Down Expand Up @@ -195,7 +199,11 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
{i18nMap[currentLocale].label}
</div>
)}
<a className="start-now-button" href={`${cloudUrl}?bd_vid=${bd_vid}`} target="_blank">
<a
className="start-now-button"
href={`${cloudUrl}?bd_vid=${semParams.bd_vid}&k=${semParams.keywords}`}
target="_blank"
>
{i18nObj.startNow}
<div className="start-now-button-wrap"></div>
</a>
Expand Down
13 changes: 11 additions & 2 deletions docs/website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,17 @@ const Home = () => {

useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
const bd_vidValue = urlParams.get('bd_vid');
sessionStorage.setItem('bd_vid', bd_vidValue);
const params: Record<string, string> = {};

const bd_vid = urlParams.get('bd_vid');
if (bd_vid) params.bd_vid = bd_vid;

const k = urlParams.get('k');
if (k) params.keywords = k;

if (Object.keys(params).length > 0) {
sessionStorage.setItem('sealos_sem', JSON.stringify(params));
}
}, []);

const HomeRender = (
Expand Down
4 changes: 2 additions & 2 deletions docs/website/src/pages/self-hosting/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const i18nObj = {
const HomeHeader = ({ isPc }: { isPc: boolean }) => {
const [stars, setStars] = useState(10000);
const isBrowser = useIsBrowser();
const { cloudUrl, bd_vid } = useWindow();
const { cloudUrl, semParams } = useWindow();

const {
i18n: { currentLocale, defaultLocale }
Expand Down Expand Up @@ -145,7 +145,7 @@ const HomeHeader = ({ isPc }: { isPc: boolean }) => {
)}
<a
className="start-now-button"
href={`${cloudUrl}?bd_vid=${bd_vid}&s=bd-sealos-self-hosting`}
href={`${cloudUrl}?bd_vid=${semParams.bd_vid}&k=${semParams.keywords}&s=bd-sealos-self-hosting`}
target="_blank"
>
{i18nObj.startNow}
Expand Down
13 changes: 11 additions & 2 deletions docs/website/src/pages/self-hosting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@ export default function Pricing() {

useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
const value = urlParams.get('bd_vid');
sessionStorage.setItem('bd_vid', value);
const params: Record<string, string> = {};

const bd_vid = urlParams.get('bd_vid');
if (bd_vid) params.bd_vid = bd_vid;

const k = urlParams.get('k');
if (k) params.keywords = k;

if (Object.keys(params).length > 0) {
sessionStorage.setItem('sealos_sem', JSON.stringify(params));
}
}, []);

return (
Expand Down
11 changes: 7 additions & 4 deletions docs/website/src/pages/self-hosting/product/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import StarIcon from '@site/static/price/star.svg';
import React from 'react';

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

const company = [
'工单/即时通信服务',
Expand Down Expand Up @@ -43,7 +42,9 @@ export default function Product() {
<div className="flex justify-center mt-14">
<div
onClick={() =>
window.open(`https://license.sealos.io/signin?bd_vid=${bd_vid}&s=bd-sealos-license`)
window.open(
`https://license.sealos.io/signin?bd_vid=${semParams.bd_vid}&k=${semParams.keywords}&s=bd-sealos-license`
)
}
className="rounded-md cursor-pointer hover:no-underline text-[#FFFFFFCC] hover:text-[#FFFFFFCC] bg-[#B7D8FF26] flex justify-center items-center font-semibold text-lg gap-2 py-3 px-4 lg:text-sm"
>
Expand Down Expand Up @@ -92,7 +93,9 @@ export default function Product() {
color: '#03080C'
}}
onClick={() =>
window.open(`https://license.sealos.io/signin?bd_vid=${bd_vid}&s=bd-sealos-license`)
window.open(
`https://license.sealos.io/signin?bd_vid=${semParams.bd_vid}&k=${semParams.keywords}&s=bd-sealos-license`
)
}
>
获取
Expand Down
Loading