File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { getExercises } from '@epic-web/workshop-utils/apps.server'
2+ import { redirect , type LoaderFunctionArgs } from '@remix-run/node'
3+
4+ export async function loader ( { request } : LoaderFunctionArgs ) {
5+ const exercises = await getExercises ( { request } )
6+ if ( ! exercises . length ) {
7+ throw new Response ( 'No exercises found' , { status : 404 } )
8+ }
9+ const lastExercise = exercises [ exercises . length - 1 ]
10+ if ( ! lastExercise || ! lastExercise . steps || ! lastExercise . steps . length ) {
11+ throw new Response ( 'No steps found in last exercise' , { status : 404 } )
12+ }
13+ const lastStep = lastExercise . steps [ lastExercise . steps . length - 1 ]
14+ if ( ! lastStep || ! lastStep . solution ) {
15+ throw new Response ( 'No solution found for last step' , { status : 404 } )
16+ }
17+ const exerciseNumber = lastExercise . exerciseNumber . toString ( ) . padStart ( 2 , '0' )
18+ const stepNumber = lastStep . stepNumber . toString ( ) . padStart ( 2 , '0' )
19+ return redirect ( `/exercise/${ exerciseNumber } /${ stepNumber } /solution` )
20+ }
21+
22+ export default function LastExerciseRedirect ( ) {
23+ return null
24+ }
Original file line number Diff line number Diff line change @@ -310,10 +310,12 @@ async function killChild(child) {
310310}
311311
312312function printSupportedKeys ( ) {
313- console . log ( chalk . bold . cyan ( '\nSupported keys:' ) )
314- console . log ( ` ${ chalk . blue ( 'o' ) } - open browser` )
315- console . log ( ` ${ chalk . green ( 'u' ) } - update repo` )
316- console . log ( ` ${ chalk . magenta ( 'r' ) } - restart` )
317- console . log ( ` ${ chalk . cyan ( 'k' ) } - Kody kudos 🐨` )
318- console . log ( ` ${ chalk . gray ( 'q' ) } (or ${ chalk . gray ( 'Ctrl+C' ) } ) - exit` )
313+ console . log ( `
314+ ${ chalk . bold . cyan ( 'Supported keys:' ) }
315+ ${ chalk . blue ( 'o' ) } - open browser
316+ ${ chalk . green ( 'u' ) } - update repo
317+ ${ chalk . magenta ( 'r' ) } - restart
318+ ${ chalk . cyan ( 'k' ) } - Kody kudos 🐨
319+ ${ chalk . gray ( 'q' ) } (or ${ chalk . gray ( 'Ctrl+C' ) } ) - exit
320+ ` )
319321}
You can’t perform that action at this time.
0 commit comments