11import type { LoaderFunctionArgs , MetaFunction } from '@remix-run/node' ;
2- import { Link , useLoaderData , useSearchParams } from '@remix-run/react' ;
2+ import { Link , PrefetchPageLinks , useLoaderData , useSearchParams } from '@remix-run/react' ;
33import { Calendar , Clock , Info , MoonIcon } from 'lucide-react' ;
44import { MouseEvent , useCallback , useState } from 'react' ;
55import { getReleasesOrUpdate } from '~/data/release-data' ;
@@ -86,7 +86,7 @@ export const loader = async (args: LoaderFunctionArgs) => {
8686 calendarData [ month ] [ day ] . stable . push ( release . version ) ;
8787 }
8888 }
89- args . context . cacheControl = 'private, max-age=30 ' ;
89+ args . context . cacheControl = 'private, max-age=120 ' ;
9090
9191 const currentMonth = currentDate . getMonth ( ) ;
9292 const currentDayOfMonth = currentDate . getDate ( ) ;
@@ -107,6 +107,7 @@ const getDaysInMonth = (year: number, month: (typeof months)[number]) => {
107107} ;
108108
109109export default function ReleaseHistory ( ) {
110+ const [ preloadAllYears , setPreloadAllYears ] = useState ( false ) ;
110111 const [ , setSearchParams ] = useSearchParams ( ) ;
111112 const {
112113 data : calendarData ,
@@ -150,6 +151,9 @@ export default function ReleaseHistory() {
150151 } ,
151152 [ setSearchParams ] ,
152153 ) ;
154+ const onYearSelectClick = useCallback ( ( ) => {
155+ setPreloadAllYears ( true ) ;
156+ } , [ ] ) ;
153157
154158 const allowedYears = [ ] ;
155159 for ( let y = MIN_YEAR ; y <= new Date ( ) . getFullYear ( ) ; y ++ ) {
@@ -158,12 +162,22 @@ export default function ReleaseHistory() {
158162
159163 return (
160164 < div className = "max-w-4xl mx-auto" >
165+ { preloadAllYears
166+ ? allowedYears . map ( ( year ) => (
167+ < PrefetchPageLinks key = { year } page = { `/history?year=${ year } ` } />
168+ ) )
169+ : null }
161170 < div className = "flex flex-col md:flex-row items-start md:items-center justify-between gap-4 mb-8" >
162171 < h2 className = "text-3xl font-bold text-[#2f3241] dark:text-white flex items-center gap-2" >
163172 < Calendar className = "w-7 h-7" />
164173 Release History { year }
165174 </ h2 >
166- < Select options = { allowedYears } selected = { `${ year } ` } onChange = { setYear } />
175+ < Select
176+ options = { allowedYears }
177+ selected = { `${ year } ` }
178+ onChange = { setYear }
179+ onClick = { onYearSelectClick }
180+ />
167181 </ div >
168182
169183 < div className = "bg-white dark:bg-gray-800 rounded-xl shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden mb-6" >
0 commit comments