parent
54c3f36e64
commit
0de4345cb7
2 changed files with 49 additions and 0 deletions
@ -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"] |
||||
} |
||||
] |
@ -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', |
||||
}, |
||||
}); |
||||
}; |
Loading…
Reference in new issue