11import clsx from 'clsx' ;
2+ import FigmaPreview from 'components/FigmaPreview' ;
3+ import Meta from 'components/Meta' ;
4+ import challenges from 'data/challenges' ;
25import { Interfaces } from 'doodle-icons' ;
36import { ExternalLink } from 'lucide-react' ;
47import Image from 'next/image' ;
58import { notFound } from 'next/navigation' ;
6-
7- import challenges from 'data/challenges' ;
8-
9- import FigmaPreview from 'components/FigmaPreview' ;
10- import Meta from 'components/Meta' ;
9+ import { getChallengeBySlug } from 'services/challenge-service' ;
1110
1211type Params = {
1312 params : {
1413 slug : string ;
1514 } ;
1615} ;
1716
18- export async function generateStaticParams ( ) {
19- return challenges . map ( challenge => ( {
20- slug : challenge . slug
21- } ) ) ;
22- }
23-
24- async function getChallenge ( slug : string ) {
25- const challenge = challenges . find ( c => c . slug === slug ) ;
26-
27- return challenge ;
28- }
29-
3017async function Page ( { params : { slug } } : Params ) {
31- const challenge = await getChallenge ( slug ) ;
18+ const [ challenge ] = await getChallengeBySlug ( { slug } ) ;
3219
3320 if ( ! challenge ) {
3421 notFound ( ) ;
@@ -37,9 +24,8 @@ async function Page({ params: { slug } }: Params) {
3724 return (
3825 < div
3926 style = { {
40- '--accent' : challenge . accent
41- } }
42- >
27+ '--accent' : challenge . accent ,
28+ } } >
4329 < FigmaPreview src = { challenge . figma } />
4430
4531 < div className = "flex flex-wrap gap-10 lg:flex-nowrap" >
@@ -49,8 +35,7 @@ async function Page({ params: { slug } }: Params) {
4935 'relative p-10 lg:p-20' ,
5036 'border-4 border-black bg-[var(--accent)]' ,
5137 'shadow-solid'
52- ) }
53- >
38+ ) } >
5439 < h1 className = "font-display text-2xl lg:text-4xl" >
5540 { challenge . name }
5641 </ h1 >
@@ -90,14 +75,12 @@ async function Page({ params: { slug } }: Params) {
9075 'relative px-10 py-10' ,
9176 'border-4 border-black bg-brand' ,
9277 'shadow-solid'
93- ) }
94- >
78+ ) } >
9579 < a
9680 href = { challenge . figma }
9781 target = "_blank"
9882 rel = "noopener noreferrer"
99- className = "flex items-center justify-center gap-4 border-2 border-black bg-[#2AE876] py-4 text-2xl"
100- >
83+ className = "flex items-center justify-center gap-4 border-2 border-black bg-[#2AE876] py-4 text-2xl" >
10184 < Interfaces . Download
10285 width = { 24 }
10386 height = { 24 }
@@ -110,8 +93,7 @@ async function Page({ params: { slug } }: Params) {
11093 < a
11194 href = "https://creativecommons.org/licenses/by/4.0/"
11295 target = "_blank"
113- rel = "noreferrer"
114- >
96+ rel = "noreferrer" >
11597 Read The License
11698 </ a >
11799 </ p >
@@ -122,8 +104,7 @@ async function Page({ params: { slug } }: Params) {
122104 'border-4 border-black bg-[#00FABE]' ,
123105 'space-y-8' ,
124106 'shadow-solid'
125- ) }
126- >
107+ ) } >
127108 < Meta
128109 icon = { Interfaces . Dashboard2 }
129110 name = "Difficulty"
@@ -139,13 +120,12 @@ async function Page({ params: { slug } }: Params) {
139120 className = { clsx (
140121 'px-10 py-10 border-4 border-black' ,
141122 'bg-[#FF508F] shadow-solid'
142- ) }
143- >
123+ ) } >
144124 < h2 className = "text-2xl font-semibold" >
145- UI { challenge . designer . length > 1 ? 'designers' : 'designer' }
125+ UI { challenge . designers . length > 1 ? 'designers' : 'designer' }
146126 </ h2 >
147127 < div className = "mt-4" >
148- { challenge . designer . map ( designer => (
128+ { challenge . designers . map ( ( designer ) => (
149129 < div key = { designer . name } className = "flex items-center mt-4" >
150130 < Image
151131 src = { designer . avatar }
@@ -159,11 +139,10 @@ async function Page({ params: { slug } }: Params) {
159139 { designer . name }
160140 </ h3 >
161141 < a
162- href = { designer . url }
142+ href = { designer . links [ 0 ] . link }
163143 target = "_blank"
164144 rel = "noopener noreferrer"
165- className = "inline-flex items-center hover:underline"
166- >
145+ className = "inline-flex items-center hover:underline" >
167146 Visit Profile < ExternalLink width = { 18 } className = "ml-2" />
168147 </ a >
169148 </ div >
0 commit comments