@@ -50,6 +50,7 @@ export async function getStaticProps({ query }: { query: any }) {
5050 slug,
5151 frontmatter,
5252 content,
53+ readingTime : Math . ceil ( readingTime ( content ) . minutes ) ,
5354 } ;
5455 } ) ;
5556
@@ -196,6 +197,7 @@ export default function StaticMarkdownPage({
196197 const [ currentPage , setCurrentPage ] = useState ( 1 ) ;
197198
198199 const totalPages = Math . ceil ( sortedFilteredPosts . length / POSTS_PER_PAGE ) ;
200+ const isFirstPage = currentPage === 1 ;
199201
200202 useEffect ( ( ) => {
201203 if ( currentPage > totalPages ) {
@@ -319,27 +321,26 @@ export default function StaticMarkdownPage({
319321 { /* Blog Posts Grid */ }
320322 < div className = 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 xl:grid-cols-5 gap-6 grid-flow-row mb-16 bg-white dark:bg-slate-800 mx-auto p-4' >
321323 { currentPagePosts . map ( ( blogPost : any , idx : number ) => {
322- const { frontmatter, content } = blogPost ;
324+ const { frontmatter } = blogPost ;
323325 const date = new Date ( frontmatter . date ) ;
324- const postTimeToRead = Math . ceil ( readingTime ( content ) . minutes ) ;
325326
326327 return (
327328 < section key = { blogPost . slug } >
328329 < Link
329330 href = { `/blog/posts/${ blogPost . slug } ` }
330- className = 'h-[600px] sm:h-[540px] flex border rounded-lg shadow-sm transition-shadow duration-300 overflow-hidden dark:border-slate-500 group flex-col flex-1 w-full '
331+ className = 'group h-[600px] sm:h-[540px] flex flex-col border rounded-lg shadow-sm transform-gpu will-change-transform transition-shadow duration-300 overflow-hidden'
331332 >
332333 < div className = 'relative w-full aspect-[16/9] overflow-hidden' >
333334 < Image
334335 src = { frontmatter . cover }
335336 alt = { frontmatter . title }
336337 fill
337- className = 'object-cover transition-transform duration-300 group-hover:scale-110'
338- loading = { idx < 10 ? 'eager' : 'lazy' }
339- priority = { idx < 10 }
338+ className = 'object-cover transform-gpu will-change-transform transition-transform duration-300 group-hover:scale-110'
339+ loading = { isFirstPage && idx < 2 ? 'eager' : 'lazy' }
340+ priority = { isFirstPage && idx < 2 }
340341 quality = { 75 }
341342 />
342- < div className = 'absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-30 transition-all duration-300 pointer-events-none' />
343+ < div className = 'absolute inset-0 bg-black bg-opacity-0 transition-opacity duration-300 group-hover:bg-opacity-30 pointer-events-none' />
343344 </ div >
344345 < div className = 'p-4 flex flex-col flex-1 justify-between min-h-0 pt-2' >
345346 < div >
@@ -359,7 +360,7 @@ export default function StaticMarkdownPage({
359360 </ div >
360361 ) ) }
361362 </ div >
362- < div className = 'text-lg h-[95px] font-semibold overflow-hidden transition-transform duration-300 group-hover:scale-105' >
363+ < div className = 'text-lg h-[95px] font-semibold overflow-hidden transform-gpu will-change-transform transition-transform duration-300 group-hover:scale-105' >
363364 { frontmatter . title }
364365 </ div >
365366 < div className = 'mt-3 text-slate-500 dark:text-slate-300 flex-1 min-h-0' >
@@ -440,7 +441,7 @@ export default function StaticMarkdownPage({
440441 </ span >
441442 </ span >
442443 < span className = 'text-slate-500 text-sm dark:text-slate-400' >
443- { postTimeToRead } min read
444+ { blogPost . readingTime } min read
444445 </ span >
445446 </ div >
446447 </ Link >
0 commit comments