Skip to content

Commit

Permalink
add baidu keywords (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk authored Nov 13, 2024
1 parent 5018020 commit 26a0a53
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
12 changes: 0 additions & 12 deletions projects/fastgpt/app/BdVidHandler.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions projects/fastgpt/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Analytics } from '@vercel/analytics/react';
import { Viewport } from 'next';
import { Inter as FontSans } from 'next/font/google';
import Script from 'next/script';
import BdVidHandler from './BdVidHandler';

const fontSans = FontSans({
subsets: ['latin'],
Expand Down Expand Up @@ -84,7 +83,6 @@ export default async function RootLayout({
</ThemeProvider>
<GoogleAnalytics />
<BaiDuAnalytics />
<BdVidHandler />
</body>
</html>
);
Expand Down
26 changes: 20 additions & 6 deletions projects/fastgpt/components/home/CTAButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import { useEffect, useState } from 'react';

const CTAButton = ({ locale, stars: initialStars, showGithub = true }: { locale: any; stars: number, showGithub?: boolean }) => {
const [stars, setStars] = useState(initialStars);
const [bd_vid, setBdVid] = useState<string | null>(null);

useEffect(() => {
setBdVid(typeof window !== 'undefined' ? localStorage.getItem('bd_vid') : null);
}, []);

useEffect(() => {
const getStars = async () => {
Expand All @@ -28,6 +23,22 @@ const CTAButton = ({ locale, stars: initialStars, showGithub = true }: { locale:
getStars();
}, [initialStars]);

const getLinkConfig = () => {
if (typeof window === 'undefined') return { pathname: siteConfig.userUrl };

const urlParams = new URLSearchParams(window.location.search);
const bd_vid = urlParams.get('bd_vid');
const k = urlParams.get('k');

return {
pathname: siteConfig.userUrl,
query: {
...(bd_vid && { bd_vid }),
...(k && { k })
}
};
};

return (
<div className="flex items-center gap-6">
{
Expand All @@ -47,7 +58,10 @@ const CTAButton = ({ locale, stars: initialStars, showGithub = true }: { locale:
</Button>
</Link>)
}
<Link href={`${siteConfig.userUrl}?bd_vid=${bd_vid}`} rel="noopener noreferrer nofollow">
<Link
href={getLinkConfig()}
rel="noopener noreferrer nofollow"
>
<Button
variant="default"
className="flex items-center gap-3 bg-[#B9DFFF] hover:bg-[#91C2EB] text-[#3941DD] px-6 py-4 text-sm"
Expand Down

0 comments on commit 26a0a53

Please sign in to comment.