File tree Expand file tree Collapse file tree 1 file changed +24
-8
lines changed
src/pages/questions/solution Expand file tree Collapse file tree 1 file changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -7,21 +7,37 @@ import Tag from "@components/Tag/Tag.astro";
77import { dynamicImport } from " @utilities/index" ;
88import { getCollection } from " astro:content" ;
99import { default as Layout } from " src/layouts/Content/Content.astro" ;
10+ import { DiscordMessageType , sendAlert } from " @utilities/discord" ;
1011
1112export async function getStaticPaths() {
1213 const questions = await getCollection (" questions" );
13- return questions
14- .filter ((question : any ) => question .id .includes (" index.md" ))
15- .map ((page ) => {
16- return {
17- params: { path: page .slug },
18- props: { page },
19- };
20- });
14+ const filteredQuestions = questions .filter ((question : any ) => {
15+ return (
16+ question .data .solution !== undefined && question .id .includes (" index.md" )
17+ );
18+ });
19+ return filteredQuestions .map ((page ) => {
20+ return {
21+ params: { path: page .slug },
22+ props: { page },
23+ };
24+ });
2125}
2226
2327const { path } = Astro .params ;
2428const { page } = Astro .props ;
29+
30+ if (page .data .solution === undefined ) {
31+ sendAlert ({
32+ type: DiscordMessageType .ERROR ,
33+ data: {
34+ message: ` Solution not found for question ${page .data .path } ` ,
35+ page: page ,
36+ path: path ,
37+ },
38+ });
39+ }
40+
2541const { Content } = await page .render ();
2642const solutionFile = await dynamicImport (
2743 ` ../../../content/questions/${page .data .solution } ` ,
You can’t perform that action at this time.
0 commit comments