@@ -5,16 +5,7 @@ import { GetStaticProps } from 'next';
55import { getPostsMetaOnly } from '../lib/posts' ;
66import AdSense from '../components/AdSense' ;
77import TopNotice from "../components/TopNotice" ;
8-
9- const gradients = [
10- 'from-pink-500 via-red-500 to-orange-400' ,
11- 'from-blue-400 to-green-400' ,
12- 'from-purple-500 to-pink-500' ,
13- 'from-yellow-400 via-green-500 to-teal-500' ,
14- 'from-indigo-500 to-sky-500' ,
15- 'from-rose-400 via-fuchsia-500 to-indigo-500' ,
16- 'from-emerald-400 to-lime-500' ,
17- ] ;
8+ import { catImages } from "../lib/mainImage" ;
189
1910type Post = {
2011 id : string ;
@@ -43,12 +34,12 @@ export const getStaticProps: GetStaticProps<HomeProps> = async () => {
4334
4435 const rest = restAll . filter ( ( post ) => post . id !== latest . id ) . slice ( 0 , 3 ) ;
4536
46- const gradientsForPosts = shuffle ( gradients ) . slice ( 0 , rest . length ) ;
37+ const shuffledImages = shuffle ( catImages ) . slice ( 0 , rest . length ) ;
4738
4839 return {
4940 props : {
5041 allPostsData,
51- gradientsForPosts,
42+ gradientsForPosts : shuffledImages ,
5243 } ,
5344 } ;
5445} ;
@@ -123,13 +114,20 @@ export default function Home({ allPostsData, gradientsForPosts }: HomeProps) {
123114 </ div >
124115 < div className = "grid md:grid-cols-3 gap-6" >
125116 { rest . map ( ( { id, title } , idx ) => (
126- < Link key = { id } href = { `/post/${ id } ` } >
127- < div
128- className = { `flex flex-col justify-end p-6 h-48 sm:h-64 rounded-xl text-white shadow hover:shadow-xl transition bg-gradient-to-br ${ gradientsForPosts [ idx ] } ` }
129- >
130- < h3 className = "text-lg font-semibold leading-snug" > { title } </ h3 >
131- </ div >
132- </ Link >
117+ < Link key = { id } href = { `/post/${ id } ` } >
118+ < div
119+ className = "flex flex-col justify-end p-6 h-48 sm:h-64 rounded-xl text-white shadow hover:shadow-xl transition"
120+ style = { {
121+ backgroundImage : `url(${ gradientsForPosts [ idx ] } )` ,
122+ backgroundSize : "cover" ,
123+ backgroundPosition : "center" ,
124+ } }
125+ >
126+ < h3 className = "text-lg font-semibold leading-snug bg-black bg-opacity-50 p-2 rounded" >
127+ { title }
128+ </ h3 >
129+ </ div >
130+ </ Link >
133131 ) ) }
134132 </ div >
135133 </ section >
0 commit comments