@@ -77,21 +77,22 @@ function filterTools(
7777export const getStaticPaths: GetStaticPaths = async () => {
7878 const curatedCollections = await getCollection (' curated-collections' );
7979 return curatedCollections .map ((collection ) => ({
80- params: { slug: collection .id },
80+ params: { slug: collection .id . replace ( / \. md $ / , ' ' ) },
8181 props: { collection },
8282 }));
8383};
8484
8585// 2. Get the collection from props
86- const { slug } = Astro .params ;
87- const collection = await getEntry (' curated-collections' , slug as string );
86+ const { collection } = Astro .props ;
8887
8988if (! collection ) {
90- throw new Error (` No collection found for slug ${slug } ` );
89+ throw new Error (` No collection found for slug ${Astro . params . slug } ` );
9190}
9291
9392const { Content } = await render (collection );
9493
94+ const slug = collection .id .replace (/ \. md$ / , ' ' );
95+
9596// 3. Get all tools and filter them based on collection filters
9697const allTools = await getCollection (' tools' );
9798const filteredTools = filterTools (allTools , collection .data .filters );
@@ -107,9 +108,9 @@ type CategoryWithTools = {
107108
108109const categoriesWithTools: CategoryWithTools [] = allCategories
109110 .map ((category ) => {
110- const categoryIdWithoutExt = category .id .replace (/ \. md$ / , ' ' );
111+ const categorySlug = category .id .replace (/ \. md$ / , ' ' );
111112 const toolsInCategory = filteredTools .filter ((tool ) =>
112- tool .data .categories ?.some ((cat ) => cat .id === categoryIdWithoutExt )
113+ tool .data .categories ?.some ((cat ) => cat .id === categorySlug )
113114 );
114115 return {
115116 category ,
@@ -130,7 +131,7 @@ const categoryGroups = categoriesWithTools.map(({ category, tools }) => ({
130131 description: category .data .description ,
131132 tools: tools .map ((tool ) => ({
132133 tool: tool .data ,
133- slug: tool .id ,
134+ slug: tool .id . replace ( / \. md $ / , ' ' ) ,
134135 category: category .data ,
135136 })),
136137}));
@@ -170,7 +171,7 @@ const categoryGroups = categoriesWithTools.map(({ category, tools }) => ({
170171 url: ` https://openapi.tools/collections/${slug } ` ,
171172 tools: filteredTools .slice (0 , 10 ).map ((tool ) => ({
172173 name: tool .data .name ,
173- url: ` https://openapi.tools/tools/${tool .id } ` ,
174+ url: ` https://openapi.tools/tools/${tool .id . replace ( / \. md $ / , ' ' ) } ` ,
174175 })),
175176 })
176177 )}
0 commit comments