@@ -4,8 +4,9 @@ import Footer from '../components/Footer';
44import { GetStaticProps } from 'next' ;
55import { getPostsMetaOnly } from '../lib/posts' ;
66import AdSense from '../components/AdSense' ;
7- import TopNotice from "../components/TopNotice" ;
8- import { catImages } from "../lib/mainImage" ;
7+ import { catImages } from '../lib/mainImage' ;
8+ import BookCard from '../components/BookCard' ;
9+ import { getBooksMetaOnly , BookMeta } from '../lib/books' ;
910
1011type Post = {
1112 id : string ;
@@ -19,6 +20,7 @@ type Post = {
1920type HomeProps = {
2021 allPostsData : Post [ ] ;
2122 gradientsForPosts : string [ ] ;
23+ latestBook ?: BookMeta | null ;
2224} ;
2325
2426function shuffle < T > ( array : T [ ] ) : T [ ] {
@@ -37,10 +39,14 @@ export const getStaticProps: GetStaticProps<HomeProps> = async () => {
3739 const rest = restAll . filter ( ( post ) => post . id !== latest . id ) . slice ( 0 , 3 ) ;
3840 const shuffledImages = shuffle ( catImages ) . slice ( 0 , rest . length ) ;
3941
42+ const books = getBooksMetaOnly ?.( ) ?? [ ] ;
43+ const latestBook = books . length > 0 ? books [ 0 ] : null ;
44+
4045 return {
4146 props : {
4247 allPostsData,
4348 gradientsForPosts : shuffledImages ,
49+ latestBook,
4450 } ,
4551 } ;
4652} ;
@@ -49,11 +55,14 @@ export const getStaticProps: GetStaticProps<HomeProps> = async () => {
4955const byDesc = ( a ?: string , b ?: string ) =>
5056 new Date ( b ?? '1970-01-01' ) . getTime ( ) - new Date ( a ?? '1970-01-01' ) . getTime ( ) ;
5157
52- export default function Home ( { allPostsData, gradientsForPosts } : HomeProps ) {
58+ export default function Home ( {
59+ allPostsData,
60+ gradientsForPosts,
61+ latestBook,
62+ } : HomeProps ) {
5363 if ( ! allPostsData . length ) {
5464 return (
5565 < >
56- < TopNotice />
5766 < Header isDark = { false } />
5867 < main className = "max-w-3xl mx-auto px-6 py-24" >
5968 < h1 className = "text-3xl font-bold" > No posts yet</ h1 >
@@ -79,7 +88,6 @@ export default function Home({ allPostsData, gradientsForPosts }: HomeProps) {
7988
8089 return (
8190 < >
82- < TopNotice />
8391 < div className = "min-h-screen" >
8492 < Header isDark = { false } />
8593
@@ -89,21 +97,26 @@ export default function Home({ allPostsData, gradientsForPosts }: HomeProps) {
8997 Hi, I’m a < strong > considerate developer</ strong > .
9098 </ h1 >
9199 < p className = "text-lg text-gray-600 leading-loose space-y-2" >
92- I believe being considerate means writing < strong > clean, readable code</ strong > ,< br />
100+ I believe being considerate means writing{ ' ' }
101+ < strong > clean, readable code</ strong > ,< br />
93102 building < strong > predictable and testable systems</ strong > ,< br />
94- and delivering < strong > reliable, trustworthy services</ strong > that users can depend on.< br /> < br />
95- I’m constantly < strong > learning and growing</ strong > to become better at this,< br />
96- and this blog is where I share my < strong > journey as a learning developer</ strong > .
103+ and delivering < strong > reliable, trustworthy services</ strong > that
104+ users can depend on.< br />
105+ < br />
106+ I’m constantly < strong > learning and growing</ strong > to become
107+ better at this,< br />
108+ and this blog is where I share my{ ' ' }
109+ < strong > journey as a learning developer</ strong > .
97110 </ p >
98111 </ section >
99112
100113 < div className = "bg-gray-50 pt-32 pb-20 px-4" >
101114 < main className = "max-w-4xl mx-auto px-4 pb-32 space-y-24" >
102115 { /* Latest Post */ }
103116 < section >
104- < span className = "inline-block px-3 py-1 text-xs font-semibold rounded-full bg-white text-gray-500 uppercase tracking-wide" >
105- Latest Post
106- </ span >
117+ < span className = "inline-block px-3 py-1 text-xs font-semibold rounded-full bg-white text-gray-500 uppercase tracking-wide" >
118+ Latest Post
119+ </ span >
107120
108121 < h2 className = "mt-4 text-3xl font-bold text-gray-900" >
109122 { latest . title }
@@ -129,9 +142,9 @@ export default function Home({ allPostsData, gradientsForPosts }: HomeProps) {
129142
130143 { /* Recently Updated */ }
131144 < section >
132- < span className = "inline-block px-3 py-1 text-xs font-semibold rounded-full bg-white text-gray-500 uppercase tracking-wide" >
133- Recently Updated
134- </ span >
145+ < span className = "inline-block px-3 py-1 text-xs font-semibold rounded-full bg-white text-gray-500 uppercase tracking-wide" >
146+ Recently Updated
147+ </ span >
135148
136149 < h2 className = "mt-4 text-3xl font-bold text-gray-900" >
137150 { updatedPost . title }
@@ -161,28 +174,49 @@ export default function Home({ allPostsData, gradientsForPosts }: HomeProps) {
161174
162175 < AdSense />
163176
177+ { /* Latest Book (1권) */ }
178+ { latestBook && (
179+ < section >
180+ < span className = "inline-block px-3 py-1 text-xs font-semibold rounded-full bg-white text-gray-500 uppercase tracking-wide" >
181+ Latest Book Review
182+ </ span >
183+
184+ < div className = "mt-6 max-w-4xl" >
185+ < BookCard meta = { latestBook } />
186+ </ div >
187+
188+ < Link
189+ href = "/book"
190+ className = "inline-block bg-green-600 hover:bg-green-700 text-white font-semibold px-6 py-2 rounded transition"
191+ >
192+ Read All Books →
193+ </ Link >
194+ </ section >
195+ ) }
196+
164197 { /* More Posts */ }
165198 < section >
166199 < div className = "flex justify-between items-center mb-4" >
167- < span className = "inline-block px-3 py-1 text-xs font-semibold rounded-full bg-white text-gray-500 uppercase tracking-wide" >
168- More Posts
169- </ span >
200+ < span className = "inline-block px-3 py-1 text-xs font-semibold rounded-full bg-white text-gray-500 uppercase tracking-wide" >
201+ More Posts
202+ </ span >
170203 < Link
171204 href = "/post"
172205 className = "text-sm text-gray-500 hover:text-gray-700 flex items-center gap-1"
173206 >
174207 Read all →
175208 </ Link >
176209 </ div >
210+
177211 < div className = "grid md:grid-cols-3 gap-6" >
178212 { rest . map ( ( { id, title } , idx ) => (
179213 < Link key = { id } href = { `/post/${ id } ` } >
180214 < div
181215 className = "flex flex-col justify-end p-6 h-48 sm:h-64 rounded-xl text-white shadow hover:shadow-xl transition"
182216 style = { {
183217 backgroundImage : `url(${ gradientsForPosts [ idx ] } )` ,
184- backgroundSize : " cover" ,
185- backgroundPosition : " center" ,
218+ backgroundSize : ' cover' ,
219+ backgroundPosition : ' center' ,
186220 } }
187221 >
188222 < h3 className = "text-lg font-semibold leading-snug bg-black/50 p-2 rounded" >
0 commit comments