Fix best practice topics not loading

feat/roadmap-slug
Kamran Ahmed 11 months ago
parent e48fa4f593
commit 33af126728
  1. 24
      src/pages/best-practices/[bestPracticeId]/[...topicId].astro

@ -1,26 +1,16 @@
---
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();
return Object.keys(topicPathMapping).map((topicSlug) => {
const topicDetails = topicPathMapping[topicSlug];
const bestPracticeId = topicDetails.bestPracticeId;
const topicId = topicSlug.replace(`/${bestPracticeId}/`, '');
return {
params: {
topicId,
bestPracticeId,
},
props: topicDetails,
};
});
}
const { file } = Astro.props as BestPracticeTopicFileType;
const { file } = topicDetails;
const fileWithoutBasePath = file.file?.replace(/.+?\/src\/data/, '/src/data');
const gitHubUrl = `https://github.com/kamranahmedse/developer-roadmap/tree/master${fileWithoutBasePath}`;

Loading…
Cancel
Save