Skip to content

Commit

Permalink
Add alert for when solution is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
MathyouMB committed Sep 8, 2024
1 parent 18dbd30 commit c785a66
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/pages/questions/solution/[...path].astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,37 @@ import Tag from "@components/Tag/Tag.astro";
import { dynamicImport } from "@utilities/index";
import { getCollection } from "astro:content";
import { default as Layout } from "src/layouts/Content/Content.astro";
import { DiscordMessageType, sendAlert } from "@utilities/discord";
export async function getStaticPaths() {
const questions = await getCollection("questions");
return questions
.filter((question: any) => question.id.includes("index.md"))
.map((page) => {
return {
params: { path: page.slug },
props: { page },
};
});
const filteredQuestions = questions.filter((question: any) => {
return (
question.data.solution !== undefined && question.id.includes("index.md")
);
});
return filteredQuestions.map((page) => {
return {
params: { path: page.slug },
props: { page },
};
});
}
const { path } = Astro.params;
const { page } = Astro.props;
if (page.data.solution === undefined) {
sendAlert({
type: DiscordMessageType.ERROR,
data: {
message: `Solution not found for question ${page.data.path}`,
page: page,
path: path,
},
});
}
const { Content } = await page.render();
const solutionFile = await dynamicImport(
`../../../content/questions/${page.data.solution}`,
Expand Down

0 comments on commit c785a66

Please sign in to comment.