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

fix github stars #34

Merged
merged 2 commits into from
May 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
48 changes: 25 additions & 23 deletions projects/fastgpt/app/[[...lang]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
import Header from "@/components/header/Header";
import Ability from "@/components/home/Ability";
import CTA from "@/components/home/CTA";
import FAQ from "@/components/home/FAQ";
import Feature from "@/components/home/Feature";
import Hero from "@/components/home/Hero";
import Pricing from "@/components/home/Pricing";
import SocialProof from "@/components/home/SocialProof";
import VideoPlayer from "@/components/home/Video";
import { defaultLocale, getDictionary, localeNames } from "@/lib/i18n";

export default async function LangHome({
params: { lang },
}: {
params: { lang?: string[] };
}) {
let langName =
lang && lang[0] && lang[0] !== "index" ? lang[0] : defaultLocale;
import Header from '@/components/header/Header';
import Ability from '@/components/home/Ability';
import CTA from '@/components/home/CTA';
import FAQ from '@/components/home/FAQ';
import Feature from '@/components/home/Feature';
import Hero from '@/components/home/Hero';
import Pricing from '@/components/home/Pricing';
import SocialProof from '@/components/home/SocialProof';
import VideoPlayer from '@/components/home/Video';
import { defaultLocale, getDictionary, localeNames } from '@/lib/i18n';

export default async function LangHome({ params: { lang } }: { params: { lang?: string[] } }) {
let langName = lang && lang[0] && lang[0] !== 'index' ? lang[0] : defaultLocale;
const dict = await getDictionary(langName);


let stars = 13 * 1000;
try {
const { stargazers_count } = await (
await fetch('https://api.github.com/repos/labring/FastGPT')
).json();
if (stargazers_count) {
stars = stargazers_count;
}
} catch (error) {}

return (
<>
<Header dict={dict} />
<main className="flex flex-col items-center py-6">
{/* Hero Section */}
<Hero locale={dict.Hero} CTALocale={dict.CTAButton} />
<Hero locale={dict.Hero} CTALocale={dict.CTAButton} stars={stars} />
<SocialProof locale={dict.SocialProof} />
{/* Can be used to display technology stack, partners, project honors, etc. */}
{/*<ScrollingLogos />*/}
Expand All @@ -43,14 +46,13 @@ export default async function LangHome({
<FAQ id="FAQ" locale={dict.FAQ} langName={langName} />

{/* CTA (Call to Action) */}
<CTA locale={dict.CTA} CTALocale={dict.CTAButton} />
<CTA locale={dict.CTA} CTALocale={dict.CTAButton} stars={stars} />
</main>
</>
);
}

export async function generateStaticParams() {
const keys = Object.keys(localeNames).map((lang) => ({ lang: [lang] }));
return [{ lang: [""] }, ...keys];
return [{ lang: [''] }, ...keys];
}

16 changes: 8 additions & 8 deletions projects/fastgpt/components/home/CTA.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
/* eslint-disable react/no-unescaped-entities */
import CTAButton from "@/components/home/CTAButton";
import { RoughNotation } from "react-rough-notation";
import CTAButton from '@/components/home/CTAButton';
import { RoughNotation } from 'react-rough-notation';

const CTA = ({ locale, CTALocale }: { locale: any; CTALocale: any; }) => {
const CTA = ({ locale, CTALocale, stars }: { locale: any; CTALocale: any; stars: number }) => {
return (
<section className="flex flex-col justify-center max-w-[88%] items-center py-16 gap-12">
<div className="flex flex-col text-center gap-4">
<h2 className="text-center">{locale.title}</h2>
<p className="text-large text-default-500">
<RoughNotation type="box" color="#b71c1c" show={true}>
{locale.description1}
</RoughNotation>{" "}
{locale.description2}{" "}
</RoughNotation>
{locale.description2}
<RoughNotation type="box" color="#b71c1c" show={true}>
{locale.description3}
</RoughNotation>{" "}
{locale.description4}{" "}
</RoughNotation>
{locale.description4}
<RoughNotation type="box" color="#b71c1c" show={true}>
{locale.description5}
</RoughNotation>
{locale.description6}
</p>
</div>
<CTAButton locale={CTALocale} />
<CTAButton locale={CTALocale} stars={stars} />
</section>
);
};
Expand Down
12 changes: 7 additions & 5 deletions projects/fastgpt/components/home/CTAButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import { RocketIcon } from 'lucide-react';
import Link from 'next/link';
import { useEffect, useState } from 'react';

const CTAButton = ({ locale }: { locale: any }) => {
const [stars, setStars] = useState(13 * 1000);
const CTAButton = ({ locale, stars: initialStars }: { locale: any; stars: number }) => {
const [stars, setStars] = useState(initialStars);

useEffect(() => {
const getStars = async () => {
try {
const { stargazers_count } = await (
await fetch('https://api.github.com/repos/labring/FastGPT', { cache: 'force-cache' })
await fetch('https://api.github.com/repos/labring/FastGPT')
).json();
setStars(stargazers_count);
if (stargazers_count && stargazers_count !== initialStars) {
setStars(stargazers_count);
}
} catch (error) {}
};
getStars();
}, []);
}, [initialStars]);

return (
<div className="flex items-center gap-4">
Expand Down
17 changes: 8 additions & 9 deletions projects/fastgpt/components/home/Hero.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"use client";
import { LineText } from "@/components/LineText";
import CTAButton from "@/components/home/CTAButton";
import { motion } from "framer-motion";

const Hero = ({ locale, CTALocale }: { locale: any; CTALocale: any; }) => {
'use client';
import { LineText } from '@/components/LineText';
import CTAButton from '@/components/home/CTAButton';
import { motion } from 'framer-motion';

const Hero = ({ locale, CTALocale, stars }: { locale: any; CTALocale: any; stars: number }) => {
return (
<>
<motion.div
Expand All @@ -14,11 +13,11 @@ const Hero = ({ locale, CTALocale }: { locale: any; CTALocale: any; }) => {
duration: 0.3,
ease: [0, 0.71, 0.2, 1],
scale: {
type: "tween", // tween spring
type: 'tween' // tween spring
// damping: 10, // if spring
// stiffness: 50, // if spring
// restDelta: 0.001, // if spring
},
}
}}
>
<section className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 pb-16 pt-16 md:pt-24 text-center">
Expand All @@ -31,7 +30,7 @@ const Hero = ({ locale, CTALocale }: { locale: any; CTALocale: any; }) => {
</p>
</section>
</motion.div>
<CTAButton locale={CTALocale} />
<CTAButton locale={CTALocale} stars={stars} />
</>
);
};
Expand Down