mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-22 08:53:01 +02:00
Fix roadmap content json not working
This commit is contained in:
@@ -214,7 +214,7 @@
|
||||
},
|
||||
"f1djN0GxoeVPr_0cl6vMq": {
|
||||
"title": "Static Typing",
|
||||
"description": "In C++, static typing means that the data type of a variable is determined at compile time, before the program is executed. This means that a variable can only be used with data of a specific type, and the compiler ensures that the operations performed with the variable are compatible with its type. If there is a mismatch , the compiler will adjust the data type of variable to match another provided it's feasible . This process is known as `Type Conversion`. If compiler not able to achieve type conversion , `Invalid Type Conversion` error will be raised during compilation of the code .\n\nC++ is a statically typed language, which means that it uses static typing to determine data types and perform type checking during compile time. This helps with ensuring type safety and can prevent certain types of errors from occurring during the execution of the program.\n\nHere's a simple code example to demonstrate static typing in C++:\n\n #include <iostream>\n \n int main() {\n int num = 65; // 'num' is statically typed as an integer\n double pi = 3.14159; // 'pi' is statically typed as a double\n char c = 'c'; // 'c' is statically typed as a char\n \n c = num; // This asssigment would convert num's value to ASCII equivalent character\n num = pi; // This assignment would convert pi's value from double type to int type\n \n std::cout << \"The value of num is: \" << num << '\\n';\n std::cout << \"The value of pi is: \" << pi << '\\n';\n std::cout << \"The value of c is: \"<< c << '\\n';\n return 0;\n }\n \n\nIn the code above, the variable `num` is statically typed as an `int`, `pi` is statically typed as a `double`, and `c` is statically typed as a `char`. If you attempt to assign the value of `pi` to `num`, the value `3.14159` will be converted to the integer `3` and assigned to `num`. Similarly, when the value of `num` is assigned to `c`, the compiler will convert the value `65` to its corresponding [ASCII](https://www.ascii-code.com) code, which is `A`.\n\nLearn more from the following resources:",
|
||||
"description": "In C++, static typing means that the data type of a variable is determined at compile time, before the program is executed. This means that a variable can only be used with data of a specific type, and the compiler ensures that the operations performed with the variable are compatible with its type. If there is a mismatch, the compiler will adjust the data type of variable to match another provided it's feasible. This process is known as `Type Conversion`. If the compiler is not able to achieve type conversion, an `Invalid Type Conversion` error will be raised during compilation of the code.\n\nC++ is a statically typed language, which means that it uses static typing to determine data types and perform type checking during compile time. This helps with ensuring type safety and can prevent certain types of errors from occurring during the execution of the program.\n\nHere's a simple code example to demonstrate static typing in C++:\n\n #include <iostream>\n \n int main() {\n int num = 65; // 'num' is statically typed as an integer\n double pi = 3.14159; // 'pi' is statically typed as a double\n char c = 'c'; // 'c' is statically typed as a char\n \n c = num; // This asssigment would convert num's value to ASCII equivalent character\n num = pi; // This assignment would convert pi's value from double type to int type\n \n std::cout << \"The value of num is: \" << num << '\\n';\n std::cout << \"The value of pi is: \" << pi << '\\n';\n std::cout << \"The value of c is: \"<< c << '\\n';\n return 0;\n }\n \n\nIn the code above, the variable `num` is statically typed as an `int`, `pi` is statically typed as a `double`, and `c` is statically typed as a `char`. If you attempt to assign the value of `pi` to `num`, the value `3.14159` will be converted to the integer `3` and assigned to `num`. Similarly, when the value of `num` is assigned to `c`, the compiler will convert the value `65` to its corresponding [ASCII](https://www.ascii-code.com) code, which is `A`.\n\nLearn more from the following resources:",
|
||||
"links": [
|
||||
{
|
||||
"title": "Type-Coversion",
|
||||
|
@@ -218,32 +218,6 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"z8-556o-PaHXjlytrawaF": {
|
||||
"title": "Writing Semantic HTML",
|
||||
"description": "Semantic HTML refers to the use of HTML markup to reinforce the meaning of web content, rather than merely defining its appearance. It involves using HTML elements that clearly describe their purpose and content. Semantic HTML improves accessibility, SEO, and code readability. Key elements include `<header>`, `<nav>`, `<main>`, `<article>`, `<section>`, `<aside>`, and `<footer>`. It also encompasses using appropriate heading levels (`<h1>` to `<h6>`), lists (`<ul>`, `<ol>`,`<li>`), and data tables (`<table>`, `<th>`, `<td>`). Semantic HTML helps screen readers interpret page content, enables better browser rendering, and provides clearer structure for developers. By using semantically correct elements, developers create more meaningful, accessible, and maintainable web documents that are easier for both humans and machines to understand and process.\n\nVisit the following resources to learn more:",
|
||||
"links": [
|
||||
{
|
||||
"title": "Guide to Writing Semantic HTML",
|
||||
"url": "https://cs.fyi/guide/writing-semantic-html",
|
||||
"type": "article"
|
||||
},
|
||||
{
|
||||
"title": "W3Schools: Semantic HTML",
|
||||
"url": "https://www.w3schools.com/html/html5_semantic_elements.asp",
|
||||
"type": "article"
|
||||
},
|
||||
{
|
||||
"title": "Semantic HTML - web.dev",
|
||||
"url": "https://web.dev/learn/html/semantic-html/",
|
||||
"type": "article"
|
||||
},
|
||||
{
|
||||
"title": "Why & When to Use Semantic HTML Elements over Div(s)",
|
||||
"url": "https://www.youtube.com/watch?v=bOUhq46fd5g",
|
||||
"type": "video"
|
||||
}
|
||||
]
|
||||
},
|
||||
"V5zucKEHnIPPjwHqsMPHF": {
|
||||
"title": "Forms and Validations",
|
||||
"description": "Before submitting data to the server, it is important to ensure all required form controls are filled out, in the correct format. This is called client-side form validation, and helps ensure data submitted matches the requirements set forth in the various form controls.\n\nVisit the following resources to learn more:",
|
||||
|
@@ -1,14 +1,13 @@
|
||||
import type { Node } from '@roadmapsh/editor';
|
||||
import matter from 'gray-matter';
|
||||
import { HTMLElement, parse } from 'node-html-parser';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import type { Node } from '@roadmapsh/editor';
|
||||
import matter from 'gray-matter';
|
||||
import { htmlToMarkdown } from '../src/lib/html';
|
||||
import { markdownToHtml } from '../src/lib/markdown';
|
||||
import type { RoadmapFrontmatter } from '../src/lib/roadmap';
|
||||
import { slugify } from '../src/lib/slugger';
|
||||
import { markdownToHtml } from '../src/lib/markdown';
|
||||
import { HTMLElement, parse } from 'node-html-parser';
|
||||
import { htmlToMarkdown } from '../src/lib/html';
|
||||
import { httpGet } from '../src/lib/http';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
@@ -22,6 +21,23 @@ export const allowedLinkTypes = [
|
||||
'podcast',
|
||||
] as const;
|
||||
|
||||
async function fetchRoadmapJson(roadmapId: string) {
|
||||
const response = await fetch(
|
||||
`https://roadmap.sh/api/v1-official-roadmap/${roadmapId}`,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch roadmap json: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
if (data.error) {
|
||||
throw new Error(`Failed to fetch roadmap json: ${data.error}`);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
// Directory containing the roadmaps
|
||||
const ROADMAP_CONTENT_DIR = path.join(__dirname, '../src/data/roadmaps');
|
||||
const allRoadmaps = await fs.readdir(ROADMAP_CONTENT_DIR);
|
||||
@@ -54,12 +70,13 @@ if (!stats || !stats.isDirectory()) {
|
||||
for (const roadmapId of editorRoadmapIds) {
|
||||
console.log(`🚀 Starting ${roadmapId}`);
|
||||
|
||||
const { response: data, error } = await httpGet(
|
||||
`${import.meta.env.PUBLIC_API_URL}/v1-official-roadmap/${roadmapId}`,
|
||||
);
|
||||
|
||||
if (error) {
|
||||
const data = await fetchRoadmapJson(roadmapId).catch((error) => {
|
||||
console.error(error);
|
||||
return null;
|
||||
});
|
||||
|
||||
if (!data) {
|
||||
console.error(`Failed to fetch roadmap json: ${roadmapId}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user