File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use client'
2+ import { useEffect } from 'react' ;
3+ import { useRouter } from 'next/navigation' ;
4+
5+ export default function ResumeRedirect ( ) {
6+ const router = useRouter ( ) ;
7+
8+ useEffect ( ( ) => {
9+ // Try multiple possible filenames
10+ const possibleFilenames = [
11+ '/Martin%20Barker%20Resume.pdf' ,
12+ '/Martin_Barker_Resume.pdf' ,
13+ '/Martin Barker Resume.pdf'
14+ ] ;
15+
16+ // Try to redirect to the first available file
17+ const tryRedirect = async ( index = 0 ) => {
18+ if ( index >= possibleFilenames . length ) {
19+ // If none work, redirect to home
20+ router . push ( '/' ) ;
21+ return ;
22+ }
23+
24+ try {
25+ const response = await fetch ( possibleFilenames [ index ] , { method : 'HEAD' } ) ;
26+ if ( response . ok ) {
27+ window . location . href = possibleFilenames [ index ] ;
28+ } else {
29+ tryRedirect ( index + 1 ) ;
30+ }
31+ } catch ( error ) {
32+ tryRedirect ( index + 1 ) ;
33+ }
34+ } ;
35+
36+ tryRedirect ( ) ;
37+ } , [ router ] ) ;
38+
39+ // Return nothing - completely invisible redirect
40+ return null ;
41+ }
You can’t perform that action at this time.
0 commit comments