|
|
@ -1,26 +1,16 @@ |
|
|
|
--- |
|
|
|
--- |
|
|
|
import { getAllBestPracticeTopicFiles } from '../../../lib/best-practice-topic'; |
|
|
|
import { getAllBestPracticeTopicFiles } from '../../../lib/best-practice-topic'; |
|
|
|
import type { BestPracticeTopicFileType } from '../../../lib/best-practice-topic'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export async function getStaticPaths() { |
|
|
|
const { topicId, bestPracticeId } = Astro.params; |
|
|
|
|
|
|
|
if (!topicId) { |
|
|
|
|
|
|
|
return new Response(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const topicSlug = `/${bestPracticeId}/${topicId}`; |
|
|
|
const topicPathMapping = await getAllBestPracticeTopicFiles(); |
|
|
|
const topicPathMapping = await getAllBestPracticeTopicFiles(); |
|
|
|
|
|
|
|
|
|
|
|
return Object.keys(topicPathMapping).map((topicSlug) => { |
|
|
|
|
|
|
|
const topicDetails = topicPathMapping[topicSlug]; |
|
|
|
const topicDetails = topicPathMapping[topicSlug]; |
|
|
|
const bestPracticeId = topicDetails.bestPracticeId; |
|
|
|
const { file } = topicDetails; |
|
|
|
const topicId = topicSlug.replace(`/${bestPracticeId}/`, ''); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
params: { |
|
|
|
|
|
|
|
topicId, |
|
|
|
|
|
|
|
bestPracticeId, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
props: topicDetails, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { file } = Astro.props as BestPracticeTopicFileType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const fileWithoutBasePath = file.file?.replace(/.+?\/src\/data/, '/src/data'); |
|
|
|
const fileWithoutBasePath = file.file?.replace(/.+?\/src\/data/, '/src/data'); |
|
|
|
const gitHubUrl = `https://github.com/kamranahmedse/developer-roadmap/tree/master${fileWithoutBasePath}`; |
|
|
|
const gitHubUrl = `https://github.com/kamranahmedse/developer-roadmap/tree/master${fileWithoutBasePath}`; |
|
|
|