computer-scienceangular-roadmapbackend-roadmapblockchain-roadmapdba-roadmapdeveloper-roadmapdevops-roadmapfrontend-roadmapgo-roadmaphactoberfestjava-roadmapjavascript-roadmapnodejs-roadmappython-roadmapqa-roadmapreact-roadmaproadmapstudy-planvue-roadmapweb3-roadmap
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
815 B
33 lines
815 B
import type { APIRoute } from 'astro'; |
|
|
|
export async function getStaticPaths() { |
|
const bestPracticeJsons = await import.meta.glob( |
|
'/src/data/best-practices/**/*.json', |
|
{ |
|
eager: true, |
|
}, |
|
); |
|
|
|
return Object.keys(bestPracticeJsons).map((filePath) => { |
|
const bestPracticeId = filePath.split('/').pop()?.replace('.json', ''); |
|
const bestPracticeJson = bestPracticeJsons[filePath] as Record<string, any>; |
|
|
|
return { |
|
params: { |
|
bestPracticeId, |
|
}, |
|
props: { |
|
bestPracticeJson: bestPracticeJson?.default, |
|
}, |
|
}; |
|
}); |
|
} |
|
|
|
export const GET: APIRoute = async function ({ params, request, props }) { |
|
return new Response(JSON.stringify(props.bestPracticeJson), { |
|
status: 200, |
|
headers: { |
|
'content-type': 'application/json', |
|
}, |
|
}); |
|
};
|
|
|