wip: remove `getStaticPaths`

pull/5494/head
Arik Chakma 8 months ago
parent 005c66c60a
commit 6866dae012
  1. 6
      src/pages/[roadmapId]/index.astro
  2. 5
      src/pages/backend/languages.astro
  3. 24
      src/pages/guides/[guideId].astro
  4. 9
      src/pages/questions/[questionGroupId].astro
  5. 42
      src/pages/u/[username]/[roadmapId]/index.astro

@ -1,5 +1,5 @@
---
import FAQs from '../../components/FAQs/FAQs.astro';
import FAQs, { type FAQType } from '../../components/FAQs/FAQs.astro';
import FrameRenderer from '../../components/FrameRenderer/FrameRenderer.astro';
import RelatedRoadmaps from '../../components/RelatedRoadmaps.astro';
import RoadmapHeader from '../../components/RoadmapHeader.astro';
@ -50,7 +50,7 @@ if (roadmapData.schema) {
}
if (roadmapFAQs.length) {
jsonLdSchema.push(generateFAQSchema(roadmapFAQs));
jsonLdSchema.push(generateFAQSchema(roadmapFAQs as unknown as FAQType[]));
}
---
@ -115,7 +115,7 @@ if (roadmapFAQs.length) {
client:only='react'
/>
<FAQs faqs={roadmapFAQs} />
<FAQs faqs={roadmapFAQs as unknown as FAQType[]} />
<RelatedRoadmaps roadmap={roadmapData} />
</div>

@ -5,7 +5,10 @@ import BaseLayout from '../../layouts/BaseLayout.astro';
import { getGuideById } from '../../lib/guide';
const guideId = 'backend-languages';
const guide = await getGuideById('backend-languages');
const guide = await getGuideById(guideId).catch(() => null);
if (!guide) {
return Astro.redirect('/404');
}
const { frontmatter: guideData } = guide;
---

@ -2,25 +2,21 @@
import GuideHeader from '../../components/GuideHeader.astro';
import MarkdownFile from '../../components/MarkdownFile.astro';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { getAllGuides, type GuideFileType } from '../../lib/guide';
import { getGuideById } from '../../lib/guide';
export interface Props {
guide: GuideFileType;
interface Params extends Record<string, string | undefined> {
guideId: string;
}
export async function getStaticPaths() {
const guides = (await getAllGuides()).filter(
(guide) => !guide.frontmatter.excludedBySlug,
);
return guides.map((guide) => ({
params: { guideId: guide.id },
props: { guide },
}));
const { guideId } = Astro.params;
if (!guideId) {
return Astro.redirect('/404');
}
const guide = await getGuideById(guideId!).catch(() => null);
if (!guide) {
return Astro.redirect('/404');
}
const { guideId } = Astro.params;
const { guide } = Astro.props;
const { frontmatter: guideData } = guide;
---

@ -6,13 +6,12 @@ import Footer from '../../components/Footer.astro';
import AstroIcon from '../../components/AstroIcon.astro';
import { QuestionsList } from '../../components/Questions/QuestionsList';
import {
getAllQuestionGroups,
getQuestionGroupById,
} from '../../lib/question-group';
import { getQuestionGroupById } from '../../lib/question-group';
const { questionGroupId } = Astro.params;
const questionGroup = await getQuestionGroupById(questionGroupId);
const questionGroup = await getQuestionGroupById(questionGroupId!).catch(
() => null,
);
if (!questionGroup) {
return Astro.redirect('/404');
}

@ -1,42 +0,0 @@
---
import { userApi } from '../../../../api/user';
import AccountLayout from '../../../../layouts/AccountLayout.astro';
import { UserProfileRoadmap } from '../../../../components/UserPublicProfile/UserProfileRoadmap';
interface Params extends Record<string, string | undefined> {
username: string;
roadmapId: string;
}
const { username, roadmapId } = Astro.params as Params;
if (!username) {
return Astro.redirect('/404');
}
const userClient = userApi(Astro as any);
const { response: userDetails, error } =
await userClient.getPublicProfile(username);
if (error || !userDetails) {
return Astro.redirect('/404');
}
const { response: roadmapDetails, error: progressError } =
await userClient.getUserProfileRoadmap(username, roadmapId);
if (progressError || !roadmapDetails) {
return Astro.redirect('/404');
}
---
<AccountLayout title={`${roadmapDetails?.title} | ${userDetails?.name}`}>
<UserProfileRoadmap
{...roadmapDetails}
username={username}
name={userDetails?.name}
resourceId={roadmapId}
isOwnProfile={userDetails?.isOwnProfile}
profileVisibility={userDetails?.profileVisibility}
client:load
/>
</AccountLayout>
Loading…
Cancel
Save