Skip to content

Commit da72391

Browse files
(SP: 3) [Frontend] Complete About page redesign: optimize DB queries, add TS types, and fix configuration
1 parent 040fdfe commit da72391

5 files changed

Lines changed: 76 additions & 66 deletions

File tree

frontend/components/about/CommunitySection.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client"
22

33
import { MessageCircle, Github, ArrowRight, ExternalLink } from "lucide-react"
4-
import { TESTIMONIALS } from "@/data/about"
4+
import { TESTIMONIALS, type Testimonial } from "@/data/about"
55

66
import Link from "next/link"
77

@@ -26,10 +26,8 @@ export function CommunitySection() {
2626
</p>
2727
</div>
2828

29-
{/* Infinite Scroll Container */}
3029
<div className="relative w-full pause-on-hover mb-16">
3130

32-
{/* Fade Edges */}
3331
<div className="pointer-events-none absolute left-0 top-0 z-10 h-full w-12 md:w-32 bg-gradient-to-r from-gray-50 dark:from-background to-transparent" />
3432
<div className="pointer-events-none absolute right-0 top-0 z-10 h-full w-12 md:w-32 bg-gradient-to-l from-gray-50 dark:from-background to-transparent" />
3533

@@ -95,7 +93,7 @@ function TestimonialCard({
9593
platform,
9694
icon: Icon,
9795
color
98-
}: any) {
96+
}: Testimonial) {
9997
return (
10098
<div className="w-[280px] md:w-[320px] shrink-0 rounded-xl border border-gray-200 dark:border-white/10 bg-white dark:bg-[#0f0f0f] p-5 shadow-sm hover:shadow-md transition-all duration-300 hover:border-gray-300 dark:hover:border-white/20 hover:-translate-y-1">
10199
<div className="mb-3 flex items-start justify-between">

frontend/components/about/TopicsSection.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { motion } from "framer-motion"
44
import { ArrowUpRight } from "lucide-react"
5-
import { TOPICS } from "@/data/about"
5+
import { TOPICS, type Topic } from "@/data/about"
66
import Image from "next/image"
77
import Link from "next/link"
88

@@ -35,7 +35,7 @@ export function TopicsSection() {
3535

3636
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4">
3737
{TOPICS.map((topic, i) => (
38-
<TopicCard key={topic.id} topic={topic} index={i} />
38+
<TopicCard key={topic.id} topic={topic as Topic} index={i} />
3939
))}
4040
</div>
4141

@@ -44,7 +44,7 @@ export function TopicsSection() {
4444
)
4545
}
4646

47-
function TopicCard({ topic, index }: { topic: any, index: number }) {
47+
function TopicCard({ topic, index }: { topic: Topic, index: number }) {
4848
return (
4949
<motion.div
5050
initial={{ opacity: 0, y: 20 }}

frontend/data/about.ts

Lines changed: 50 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
import { Twitter, Linkedin, Github } from "lucide-react"
22

33
export const TESTIMONIALS = [
4-
{
5-
name: "Alex Chen",
6-
role: "Frontend @ Meta",
7-
avatar: "AC",
8-
content: "Cheap therapy for React devs.",
9-
platform: "Twitter",
10-
icon: Twitter,
11-
color: "text-sky-500 bg-sky-500/10"
12-
},
13-
{
14-
name: "Sarah J.",
15-
role: "Senior SWE @ Google",
16-
avatar: "SJ",
17-
content: "Harder than my actual interview. 10/10.",
18-
platform: "LinkedIn",
19-
icon: Linkedin,
20-
color: "text-blue-600 bg-blue-600/10"
21-
},
22-
{
23-
name: "git_push_force",
24-
role: "Open Source Contributor",
25-
avatar: "GP",
26-
content: "Found a bug in the quiz, reported it, got points. Now I'm addicted to fixing your typos.",
27-
platform: "GitHub",
28-
icon: Github,
29-
color: "text-gray-900 dark:text-white bg-gray-500/10"
30-
},
31-
{
32-
name: "Emily Park",
33-
role: "Full Stack @ Vercel",
34-
avatar: "EP",
35-
content: "This is the only place where 'centering a div' is explained like I'm 5. Bless you.",
36-
platform: "Twitter",
37-
icon: Twitter,
38-
color: "text-sky-500 bg-sky-500/10"
39-
},
40-
{
41-
name: "David Kim",
42-
role: "Staff Engineer @ Netflix",
43-
avatar: "DK",
44-
content: "I use the Q&A section to win arguments with my juniors. Don't tell them.",
45-
platform: "LinkedIn",
46-
icon: Linkedin,
47-
color: "text-blue-600 bg-blue-600/10"
48-
},
4+
{
5+
name: "Alex Chen",
6+
role: "Frontend @ Meta",
7+
avatar: "AC",
8+
content: "Cheap therapy for React devs.",
9+
platform: "Twitter",
10+
icon: Twitter,
11+
color: "text-sky-500 bg-sky-500/10"
12+
},
13+
{
14+
name: "Sarah J.",
15+
role: "Senior SWE @ Google",
16+
avatar: "SJ",
17+
content: "Harder than my actual interview. 10/10.",
18+
platform: "LinkedIn",
19+
icon: Linkedin,
20+
color: "text-blue-600 bg-blue-600/10"
21+
},
22+
{
23+
name: "git_push_force",
24+
role: "Open Source Contributor",
25+
avatar: "GP",
26+
content: "Found a bug in the quiz, reported it, got points. Now I'm addicted to fixing your typos.",
27+
platform: "GitHub",
28+
icon: Github,
29+
color: "text-gray-900 dark:text-white bg-gray-500/10"
30+
},
31+
{
32+
name: "Emily Park",
33+
role: "Full Stack @ Vercel",
34+
avatar: "EP",
35+
content: "This is the only place where 'centering a div' is explained like I'm 5. Bless you.",
36+
platform: "Twitter",
37+
icon: Twitter,
38+
color: "text-sky-500 bg-sky-500/10"
39+
},
40+
{
41+
name: "David Kim",
42+
role: "Staff Engineer @ Netflix",
43+
avatar: "DK",
44+
content: "I use the Q&A section to win arguments with my juniors. Don't tell them.",
45+
platform: "LinkedIn",
46+
icon: Linkedin,
47+
color: "text-blue-600 bg-blue-600/10"
48+
},
4949
]
5050

5151
export const TOPICS = [
52-
{
52+
{
5353
id: "git",
5454
name: "Git & Version Control",
5555
questions: "90+ Questions",
@@ -140,4 +140,7 @@ export const TOPICS = [
140140
glow: "bg-[#339933]",
141141
href: "/q&a/?category=node"
142142
},
143-
]
143+
]
144+
145+
export type Topic = typeof TOPICS[number];
146+
export type Testimonial = typeof TESTIMONIALS[number];

frontend/lib/about/stats.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,35 @@ const formatMetric = (n: number) => {
1818

1919
export const getPlatformStats = unstable_cache(
2020
async (): Promise<PlatformStats> => {
21-
// 1. GitHub
2221
let stars = 125
2322
try {
2423
const headers: HeadersInit = {}
2524
if (process.env.GITHUB_TOKEN) headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`
2625

27-
// Додаємо тип any для опцій fetch, щоб TS не лаявся на next.js розширення
2826
const res = await fetch('https://api.github.com/repos/DevLoversTeam/devlovers.net', {
29-
headers,
30-
next: { revalidate: 3600 }
31-
} as RequestInit & { next?: { revalidate?: number } })
27+
headers,
28+
cache: 'no-store'
29+
})
3230

33-
if (res.ok) stars = (await res.json()).stargazers_count
34-
} catch (e) { console.error(e) }
31+
if (res.ok) {
32+
const data = await res.json()
33+
stars = data.stargazers_count
34+
}
35+
} catch (e) {
36+
console.error("GitHub Fetch Error:", e)
37+
}
3538

36-
// 2. LinkedIn
3739
const linkedinCount = process.env.LINKEDIN_FOLLOWER_COUNT ? parseInt(process.env.LINKEDIN_FOLLOWER_COUNT) : 1342
3840

39-
// 3. DB
4041
let totalUsers = 243
4142
let solvedTests = 1890
4243
try {
43-
const [u] = await db.select({ value: count() }).from(users)
44+
const [[u], [q]] = await Promise.all([
45+
db.select({ value: count() }).from(users),
46+
db.select({ value: count() }).from(quizAttempts)
47+
])
48+
4449
if (u) totalUsers = u.value
45-
const [q] = await db.select({ value: count() }).from(quizAttempts)
4650
if (q) solvedTests = q.value
4751
} catch (e) {
4852
console.error("DB Fetch Error:", e)

frontend/next.config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ const nextConfig: NextConfig = {
4141
hostname: "github.com",
4242
pathname: "/**",
4343
},
44+
{
45+
protocol: 'https',
46+
hostname: 'cdn.jsdelivr.net',
47+
pathname: '/**',
48+
},
4449
],
4550
},
4651
};
4752

48-
export default withNextIntl(nextConfig);
53+
export default withNextIntl(nextConfig);

0 commit comments

Comments
 (0)