Skip to content

Commit 988f98a

Browse files
committed
add md to html feature for courseData
1 parent bce6906 commit 988f98a

File tree

4 files changed

+56
-42
lines changed

4 files changed

+56
-42
lines changed

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@popperjs/core": "^2.11.8",
1414
"bootstrap": "^5.3.3",
1515
"firebase": "^10.13.1",
16+
"marked": "^14.1.2",
1617
"react": "^18.3.1",
1718
"react-dom": "^18.3.1",
1819
"react-router-dom": "^6.26.2",

src/components/CourseDetail.jsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { useParams } from 'react-router-dom';
33
import courses from './courseData'; // Ensure the path is correct
44
import YouTubeEmbed from './YouTubeEmbed';
5+
import { marked } from 'marked'; // Import the marked library
56

67
function CourseDetail() {
78
const { courseName } = useParams();
@@ -12,14 +13,9 @@ function CourseDetail() {
1213
return <h2 className="text-center">Course not found</h2>;
1314
}
1415

15-
// Function to convert newlines to <br />
16-
const formatContent = (content) => {
17-
return content.split('\n').map((line, index) => (
18-
<span key={index}>
19-
{line}
20-
<br />
21-
</span>
22-
));
16+
// Function to convert markdown to HTML using 'marked'
17+
const renderMarkdown = (markdownText) => {
18+
return { __html: marked(markdownText) };
2319
};
2420

2521
return (
@@ -29,7 +25,10 @@ function CourseDetail() {
2925
<p>{course.description}</p>
3026
<h4>Course Content:</h4>
3127
<YouTubeEmbed videoId={course.ytb_vid} />
32-
<p>{formatContent(course.content)}</p>
28+
29+
{/* Use dangerouslySetInnerHTML to inject the HTML from the markdown */}
30+
<div dangerouslySetInnerHTML={renderMarkdown(course.content)} />
31+
3332
<h6><span className="badge bg-primary"><i className="fa-solid fa-pen-nib"></i> {course.author}</span></h6>
3433
</div>
3534
);

src/components/courseData.js

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const courses = {
66
description: 'Learn how to automate your development workflows with GitHub Actions.',
77
ytb_vid: 'C7bHn1ZZCXI',
88
content: `
9-
This course will cover:
9+
\n # This course will cover:
1010
\n- Setting up GitHub Actions
1111
\n- Automating CI/CD pipelines
1212
\n- Managing workflows with YAML files
@@ -21,11 +21,12 @@ const courses = {
2121
description: 'Deploy static websites using GitHub Pages.',
2222
ytb_vid: 'C7bHn1ZZCXI',
2323
content: `
24-
Learn how to:
24+
\n# Learn how to:
2525
\n- Host websites on GitHub Pages
2626
\n- Use custom domains
2727
\n- Automate deployment with GitHub Actions
2828
\n- Debug common issues
29+
2930
`,
3031
},
3132
'course 3: introduction to firebase': {
@@ -35,7 +36,7 @@ const courses = {
3536
description: 'Get started with Firebase to build modern web and mobile apps.',
3637
ytb_vid: 'C7bHn1ZZCXI',
3738
content: `
38-
This course covers:
39+
\n# This course covers:
3940
\n- Setting up Firebase projects
4041
\n- Using Firestore for real-time databases
4142
\n- Firebase Authentication
@@ -49,7 +50,7 @@ const courses = {
4950
description: 'Learn how to use Cloudflare to enhance website performance and security.',
5051
ytb_vid: 'C7bHn1ZZCXI',
5152
content: `
52-
In this course, you will learn:
53+
In# This course, you will learn:
5354
\n- DNS management
5455
\n- Cloudflare CDN
5556
\n- DDoS protection
@@ -63,7 +64,7 @@ const courses = {
6364
description: 'A comprehensive guide to understanding domain registration and hosting.',
6465
ytb_vid: 'C7bHn1ZZCXI',
6566
content: `
66-
Learn about:
67+
\n # Learn about:
6768
\n- Domain registration
6869
\n- Hosting options and services
6970
\n- DNS configuration
@@ -77,7 +78,7 @@ const courses = {
7778
description: 'Learn how to create and deploy a Discord bot using JavaScript.',
7879
ytb_vid: 'C7bHn1ZZCXI',
7980
content: `
80-
This course will cover:
81+
\n# This course will cover:
8182
\n- Setting up a Discord bot
8283
\n- Using Discord.js library
8384
\n- Handling events and commands
@@ -91,7 +92,7 @@ const courses = {
9192
description: 'Create and manage a Telegram bot using the Telegram Bot API.',
9293
ytb_vid: 'C7bHn1ZZCXI',
9394
content: `
94-
Learn how to:
95+
\n # Learn how to:
9596
\n- Set up a Telegram bot
9697
\n- Handle messages and commands
9798
\n- Integrate webhooks for real-time responses
@@ -105,7 +106,7 @@ const courses = {
105106
description: 'Master the art of integrating webhooks into your applications.',
106107
ytb_vid: 'C7bHn1ZZCXI',
107108
content: `
108-
This course will teach:
109+
\n# This course will teach:
109110
\n- What webhooks are and how they work
110111
\n- Setting up webhooks in your application
111112
\n- Handling incoming requests
@@ -119,7 +120,7 @@ const courses = {
119120
description: 'Enhance your terminal experience with OH MY ZSH.',
120121
ytb_vid: 'C7bHn1ZZCXI',
121122
content: `
122-
This course covers:
123+
\n# This course covers:
123124
\n- Installing and configuring OH MY ZSH
124125
\n- Customizing ZSH themes and plugins
125126
\n- Productivity tips for terminal users
@@ -132,7 +133,7 @@ const courses = {
132133
description: 'Learn how to create a productive and visually appealing terminal environment.',
133134
ytb_vid: 'C7bHn1ZZCXI',
134135
content: `
135-
This course will teach you:
136+
\n# This course will teach you:
136137
\n- Customizing terminal prompts and colors
137138
\n- Installing and using terminal extensions
138139
\n- Workflow automation in terminal
@@ -145,7 +146,7 @@ const courses = {
145146
description: 'A complete guide to operating and optimizing your Windows system for development.',
146147
ytb_vid: 'C7bHn1ZZCXI',
147148
content: `
148-
This course covers:
149+
\n# This course covers:
149150
\n- Essential Windows commands and shortcuts
150151
\n- Setting up a development environment
151152
\n- Optimizing system performance for coding
@@ -158,7 +159,7 @@ const courses = {
158159
description: 'Master Linux commands and workflows for software development.',
159160
ytb_vid: 'C7bHn1ZZCXI',
160161
content: `
161-
Learn how to:
162+
\n # Learn how to:
162163
\n- Navigate Linux file systems
163164
\n- Work with terminal commands
164165
\n- Set up environments for coding and deployment
@@ -171,7 +172,7 @@ const courses = {
171172
description: 'Build and showcase your skills with a professional online portfolio.',
172173
ytb_vid: 'C7bHn1ZZCXI',
173174
content: `
174-
This course will teach:
175+
\n# This course will teach:
175176
\n- Structuring and designing portfolios
176177
\n- Using frameworks like Bootstrap or Tailwind
177178
\n- Hosting and deploying your portfolio site
@@ -184,7 +185,7 @@ const courses = {
184185
description: 'Learn about effective indexing strategies for databases.',
185186
ytb_vid: 'C7bHn1ZZCXI',
186187
content: `
187-
In this course, you will learn:
188+
In# This course, you will learn:
188189
\n- Types of indexing methods
189190
\n- Implementing indexing in databases
190191
\n- Optimizing queries with indexing
@@ -197,7 +198,7 @@ const courses = {
197198
description: 'Dive deeper into GitHub features and best practices.',
198199
ytb_vid: 'C7bHn1ZZCXI',
199200
content: `
200-
This course covers:
201+
\n# This course covers:
201202
\n- Advanced branching strategies
202203
\n- Managing pull requests and code reviews
203204
\n- Leveraging GitHub Actions for CI/CD
@@ -210,7 +211,7 @@ const courses = {
210211
description: 'Learn how to build cross-platform apps with Flutter.',
211212
ytb_vid: 'C7bHn1ZZCXI',
212213
content: `
213-
This course will teach:
214+
\n# This course will teach:
214215
\n- Setting up Flutter environment
215216
\n- Building layouts and navigation
216217
\n- Integrating APIs and services
@@ -223,7 +224,7 @@ const courses = {
223224
description: 'Master the fundamentals of data structures and algorithms.',
224225
ytb_vid: 'C7bHn1ZZCXI',
225226
content: `
226-
In this course, you will learn:
227+
\n# This course, you will learn:
227228
\n- Common data structures
228229
\n- Algorithm design techniques
229230
\n- Complexity analysis
@@ -236,7 +237,7 @@ const courses = {
236237
description: 'Get introduced to the world of machine learning.',
237238
ytb_vid: 'C7bHn1ZZCXI',
238239
content: `
239-
This course covers:
240+
\n# This course covers:
240241
\n- Key concepts of machine learning
241242
\n- Supervised vs unsupervised learning
242243
\n- Implementing basic algorithms in Python
@@ -249,7 +250,7 @@ const courses = {
249250
description: 'Understand the basics of cyber security and how to protect systems.',
250251
ytb_vid: 'C7bHn1ZZCXI',
251252
content: `
252-
Learn about:
253+
\n # Learn about:
253254
\n- Common threats and vulnerabilities
254255
\n- Security measures and best practices
255256
\n- Incident response strategies
@@ -262,7 +263,7 @@ const courses = {
262263
description: 'Learn how to scrape web data using Python libraries.',
263264
ytb_vid: 'C7bHn1ZZCXI',
264265
content: `
265-
This course will teach you:
266+
\n# This course will teach you:
266267
\n- Using BeautifulSoup and Scrapy
267268
\n- Handling web requests and responses
268269
\n- Storing scraped data for analysis
@@ -275,7 +276,7 @@ const courses = {
275276
description: 'Create RESTful APIs using Flask in Python.',
276277
ytb_vid: 'C7bHn1ZZCXI',
277278
content: `
278-
In this course, you will learn:
279+
In# This course, you will learn:
279280
\n- Setting up Flask environment
280281
\n- Creating routes and handling requests
281282
\n- Integrating with databases
@@ -288,7 +289,7 @@ const courses = {
288289
description: 'Explore popular front-end frameworks like React, Angular, and Vue.js.',
289290
ytb_vid: 'C7bHn1ZZCXI',
290291
content: `
291-
Learn about:
292+
\n # Learn about:
292293
\n- Comparing different frameworks
293294
\n- Setting up development environments
294295
\n- Building projects with chosen frameworks
@@ -301,7 +302,7 @@ const courses = {
301302
description: 'Learn to build scalable applications using Node.js.',
302303
ytb_vid: 'C7bHn1ZZCXI',
303304
content: `
304-
This course covers:
305+
\n# This course covers:
305306
\n- Setting up Node.js environment
306307
\n- Creating servers and APIs
307308
\n- Handling asynchronous programming
@@ -314,7 +315,7 @@ const courses = {
314315
description: 'Master testing and debugging techniques for software development.',
315316
ytb_vid: 'C7bHn1ZZCXI',
316317
content: `
317-
Learn how to:
318+
\n # Learn how to:
318319
\n- Write unit and integration tests
319320
\n- Use testing frameworks
320321
\n- Debugging techniques and tools
@@ -327,7 +328,7 @@ const courses = {
327328
description: 'Understand DevOps practices and principles for better collaboration.',
328329
ytb_vid: 'C7bHn1ZZCXI',
329330
content: `
330-
This course will teach:
331+
\n# This course will teach:
331332
\n- Continuous integration and delivery
332333
\n- Infrastructure as code
333334
\n- Monitoring and logging best practices
@@ -340,7 +341,7 @@ const courses = {
340341
description: 'Learn the basics of containerization using Docker.',
341342
ytb_vid: 'C7bHn1ZZCXI',
342343
content: `
343-
In this course, you will learn:
344+
In# This course, you will learn:
344345
\n- Setting up Docker environment
345346
\n- Building and running containers
346347
\n- Managing container orchestration
@@ -353,7 +354,7 @@ const courses = {
353354
description: 'Build mobile applications using React Native framework.',
354355
ytb_vid: 'C7bHn1ZZCXI',
355356
content: `
356-
This course covers:
357+
\n# This course covers:
357358
\n- Setting up React Native environment
358359
\n- Building UI components
359360
\n- Managing state and navigation
@@ -366,7 +367,7 @@ const courses = {
366367
description: 'Learn how to work with APIs for integrating services.',
367368
ytb_vid: 'C7bHn1ZZCXI',
368369
content: `
369-
Learn about:
370+
\n # Learn about:
370371
\n- Types of APIs (REST, SOAP)
371372
\n- Consuming APIs in applications
372373
\n- API authentication and security
@@ -379,7 +380,7 @@ const courses = {
379380
description: 'Automate repetitive tasks using Python scripts.',
380381
ytb_vid: 'C7bHn1ZZCXI',
381382
content: `
382-
This course will teach you:
383+
\n# This course will teach you:
383384
\n- Writing scripts for automation
384385
\n- Using libraries for web scraping and API calls
385386
\n- Scheduling tasks with cron jobs
@@ -392,7 +393,7 @@ const courses = {
392393
description: 'Enhance your communication skills in technical environments.',
393394
ytb_vid: 'C7bHn1ZZCXI',
394395
content: `
395-
Learn how to:
396+
\n # Learn how to:
396397
\n- Communicate technical concepts clearly
397398
\n- Collaborate with teams effectively
398399
\n- Present ideas and projects
@@ -405,7 +406,7 @@ const courses = {
405406
description: 'Understand the basics of ethical hacking and cybersecurity.',
406407
ytb_vid: 'C7bHn1ZZCXI',
407408
content: `
408-
This course covers:
409+
\n# This course covers:
409410
\n- Key concepts of ethical hacking
410411
\n- Common tools and techniques
411412
\n- Legal and ethical considerations
@@ -418,7 +419,7 @@ const courses = {
418419
description: 'Learn to create immersive experiences in virtual reality.',
419420
ytb_vid: 'C7bHn1ZZCXI',
420421
content: `
421-
This course will teach you:
422+
\n# This course will teach you:
422423
\n- Basics of VR technologies
423424
\n- Creating VR applications using Unity
424425
\n- Designing immersive user experiences
@@ -431,7 +432,7 @@ const courses = {
431432
description: 'Learn the fundamentals of programming and problem-solving techniques.',
432433
ytb_vid: 'Z1Yd7upQsXY',
433434
content: `
434-
This course will introduce you to:
435+
\n# This course will introduce you to:
435436
\n- Basic programming concepts and logic
436437
\n- Writing your first code in Python
437438
\n- Problem-solving strategies

0 commit comments

Comments
 (0)