File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -4,23 +4,30 @@ import courses from './courseData'; // Ensure the path is correct
4
4
5
5
function CourseDetail ( ) {
6
6
const { courseName } = useParams ( ) ;
7
-
8
- // Convert the URL back to the sanitized course key
9
- const courseKey = courseName . toLowerCase ( ) ; // Ensures proper formatting
10
-
7
+ const courseKey = courseName . toLowerCase ( ) ; // Ensure proper formatting
11
8
const course = courses [ courseKey ] ; // Lookup using the sanitized course key
12
9
13
10
if ( ! course ) {
14
11
return < h2 className = "text-center" > Course not found</ h2 > ;
15
12
}
16
13
14
+ // Function to convert newlines to <br />
15
+ const formatContent = ( content ) => {
16
+ return content . split ( '\n' ) . map ( ( line , index ) => (
17
+ < span key = { index } >
18
+ { line }
19
+ < br />
20
+ </ span >
21
+ ) ) ;
22
+ } ;
23
+
17
24
return (
18
25
< div className = "container mt-5" >
19
26
< h2 > { course . title } </ h2 >
20
27
< img src = { course . image } alt = { course . title } className = "img-fluid" />
21
28
< p > { course . description } </ p >
22
29
< h4 > Course Content:</ h4 >
23
- < p > { course . content } </ p >
30
+ < p > { formatContent ( course . content ) } </ p >
24
31
</ div >
25
32
) ;
26
33
}
You can’t perform that action at this time.
0 commit comments