1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-02 22:02:39 +02:00

Add courses json file in the frontend roadmap

This commit is contained in:
Kamran Ahmed
2024-08-20 19:13:25 +01:00
parent 54c3f36e64
commit 0de4345cb7
2 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
[
{
"id": "1",
"title": "HTML in 50 days",
"description": "Learn HTML in 50 days",
"url": "https://www.youtube.com/watch?v=xR33433-EE",
"topicIds": ["348318888", "234837387834"]
},
{
"id": "2",
"title": "CSS in 50 days",
"description": "Learn HTML in 50 days",
"url": "https://www.youtube.com/watch?v=xR33433-EE",
"topicIds": ["348318888", "234837387834"]
}
]

View File

@@ -0,0 +1,33 @@
import type { APIRoute } from 'astro';
import { getRoadmapIds } from '../../lib/roadmap.ts';
export async function getStaticPaths() {
const coursesJsons: Record<string, any> = import.meta.glob(
'/src/data/roadmaps/**/courses.json',
{
eager: true,
},
);
const roadmapIds = await getRoadmapIds();
return roadmapIds.map((roadmapId) => ({
params: {
roadmapId,
},
props: {
courses:
coursesJsons[`/src/data/roadmaps/${roadmapId}/courses.json`]?.default ||
{},
},
}));
}
export const GET: APIRoute = async function ({ params, request, props }) {
return new Response(JSON.stringify(props.courses), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});
};