File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -111,13 +111,23 @@ class App extends React.Component {
111111 const courseObj = courses . find (
112112 course => course . slug === props . match . params . course ,
113113 ) ;
114- if ( ! courseObj ) return < ErrorPage /> ;
114+ const prevCourse = courses . find (
115+ course => course . order === courseObj . order - 1 ,
116+ ) ;
117+ const nextCourse = courses . find (
118+ course => course . order === courseObj . order + 1 ,
119+ ) ;
120+ const order = parseInt ( props . match . params . order , 10 ) ;
121+ if ( ! courseObj || order >= courseObj . lessons . length ) return < ErrorPage /> ;
115122 return (
116123 < LessonPage
117124 { ...props }
125+ course_title = { courseObj . title }
118126 lessons = { courseObj . lessons }
119- curr_lesson_num = { parseInt ( props . match . params . order , 10 ) }
120- base_path = { props . match . params . course }
127+ curr_lesson_num = { order }
128+ base_path = { courseObj . slug }
129+ prev_slug = { prevCourse ? prevCourse . slug : undefined }
130+ next_slug = { nextCourse ? nextCourse . slug : undefined }
121131 />
122132 ) ;
123133 } }
You can’t perform that action at this time.
0 commit comments