Skip to content

Commit 6d52ead

Browse files
committed
add new cms
1 parent 05baf54 commit 6d52ead

File tree

7 files changed

+800
-584
lines changed

7 files changed

+800
-584
lines changed

src/App.css

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
.App {
2-
/* text-align: center; */
3-
}
4-
5-
.App-logo {
6-
height: 40vmin;
7-
pointer-events: none;
8-
}
9-
10-
@media (prefers-reduced-motion: no-preference) {
11-
.App-logo {
12-
animation: App-logo-spin infinite 20s linear;
13-
}
1+
:root {
2+
--primary-color: rgb(186 22 163);
143
}
154

165
.App-header {
@@ -24,7 +13,7 @@
2413
color: white;
2514
}
2615
.lnk {
27-
color: rgb(186 22 163) ;
16+
color: var(--primary-color);
2817
text-decoration: none ;
2918
}
3019
.clk{
@@ -53,3 +42,12 @@ background: rgb(186 22 163) !important;
5342
.search-expanded .form-control {
5443
width: 300px; /* You can adjust this width */
5544
}
45+
input, textarea{
46+
border: 1px solid var(--primary-color) !important;
47+
}
48+
.input-group span{
49+
border: 1px solid var(--primary-color) !important;
50+
}
51+
.btn-primary{
52+
background-color: var(--primary-color) !important;
53+
}

src/App.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Navbar from './components/Navbar';
2121
import CourseDetail from './components/CourseDetail';
2222
import Dashboard from './components/dashboard';
2323
import courses from './components/courseData';
24-
24+
import UploadCourse from './components/uploadCourse';
2525
function App() {
2626
const [user, setUser] = useState(null);
2727

@@ -68,7 +68,7 @@ function App() {
6868
<Route path="/courses/:courseName" element={<CourseDetail />} />
6969
<Route path="/" element={<Dashboard courses={courses} />} />
7070
<Route path="/search" element={<SearchResults />} />
71-
71+
<Route path="/admin" element={<UploadCourse/>} />
7272
</Routes>
7373
<ToastContainer />
7474
</div>

src/components/CourseDetail.jsx

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
1-
import React from 'react';
1+
import React, { useState, useEffect } from 'react';
22
import { useParams } from 'react-router-dom';
3-
import courses from './courseData'; // Ensure the path is correct
3+
import courseData from './courseData'; // Ensure correct path
44
import YouTubeEmbed from './YouTubeEmbed';
5-
import { marked } from 'marked'; // Import the marked library
65

76
function CourseDetail() {
87
const { courseName } = useParams();
98
const courseKey = courseName.toLowerCase(); // Ensure proper formatting
10-
const course = courses[courseKey]; // Lookup using the sanitized course key
9+
const [course, setCourse] = useState(null); // Store course data
10+
const [loading, setLoading] = useState(true); // Loading state
11+
12+
useEffect(() => {
13+
const loadCourseData = async () => {
14+
try {
15+
const courses = await courseData(); // Fetch courses from Firestore
16+
setCourse(courses[courseKey]); // Set the specific course
17+
} catch (error) {
18+
console.error("Error fetching course:", error);
19+
}
20+
setLoading(false); // Stop loading once data is fetched
21+
};
22+
23+
loadCourseData();
24+
}, [courseKey]);
25+
26+
if (loading) {
27+
return <h2 className="text-center">Loading...</h2>;
28+
}
1129

1230
if (!course) {
31+
console.log(course);
1332
return <h2 className="text-center">Course not found</h2>;
1433
}
1534

16-
// Function to convert markdown to HTML using 'marked'
17-
const renderMarkdown = (markdownText) => {
18-
return { __html: marked(markdownText) };
35+
// Function to convert newlines to <br />
36+
const formatContent = (content) => {
37+
return content ? content.split('\n').map((line, index) => (
38+
<span key={index}>
39+
{line}
40+
<br />
41+
</span>
42+
)) : '';
1943
};
2044

2145
return (
@@ -25,10 +49,7 @@ function CourseDetail() {
2549
<p>{course.description}</p>
2650
<h4>Course Content:</h4>
2751
<YouTubeEmbed videoId={course.ytb_vid} />
28-
29-
{/* Use dangerouslySetInnerHTML to inject the HTML from the markdown */}
30-
<div dangerouslySetInnerHTML={renderMarkdown(course.content)} />
31-
52+
<p>{formatContent(course.content)}</p>
3253
<h6><span className="badge bg-primary"><i className="fa-solid fa-pen-nib"></i> {course.author}</span></h6>
3354
</div>
3455
);

0 commit comments

Comments
 (0)