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

add baidu keywords #76

Merged
merged 1 commit into from
Nov 13, 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
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