From 90fd9d72323a111d18b7182de0e97156ce9dc640 Mon Sep 17 00:00:00 2001 From: Kian Newman-Hazel Date: Wed, 20 Nov 2024 16:21:02 +0000 Subject: [PATCH 1/2] [Docs Site] Add filters to Learning Paths overview --- src/pages/learning-paths.astro | 210 +++++++++++++++++++++++++++++++-- 1 file changed, 198 insertions(+), 12 deletions(-) diff --git a/src/pages/learning-paths.astro b/src/pages/learning-paths.astro index 0c2800cdb52e04c..58767132aa9b270 100644 --- a/src/pages/learning-paths.astro +++ b/src/pages/learning-paths.astro @@ -1,6 +1,6 @@ --- import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro"; -import { getCollection } from "astro:content"; +import { getCollection, type CollectionEntry } from "astro:content"; import { marked } from "marked"; import { CardGrid, LinkTitleCard, Description } from "~/components"; @@ -12,21 +12,207 @@ const frontmatter = { } as const; const learningPaths = await getCollection("learning-paths"); + +function lpGroups(paths: Array>) { + const groups = paths.flatMap((p) => p.data.product_group ?? []); + const additional = paths.flatMap((p) => p.data.additional_groups ?? []); + + const unique = [...new Set(groups.concat(additional))]; + + return unique.sort(); +} + +function lpProducts(paths: Array>) { + const products = paths.flatMap((p) => p.data.products ?? []); + + const unique = [...new Set(products)]; + + return unique.sort(); +} + +const groups = lpGroups(learningPaths); +const products = lpProducts(learningPaths); --- {frontmatter.description} - - { - learningPaths.map((lp) => ( - - )) - } - +
+ +
+ + { + learningPaths + .sort((a, b) => a.data.priority - b.data.priority) + .map((lp) => ( +
+ +
+ )) + } +
+
+
+ + From 09c7d7afcd5e4f595f7de1e2908e82998d1fcc03 Mon Sep 17 00:00:00 2001 From: Kian Newman-Hazel Date: Thu, 21 Nov 2024 14:25:55 +0000 Subject: [PATCH 2/2] remove logs --- src/pages/learning-paths.astro | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/pages/learning-paths.astro b/src/pages/learning-paths.astro index 58767132aa9b270..07dbbd8c6a7b739 100644 --- a/src/pages/learning-paths.astro +++ b/src/pages/learning-paths.astro @@ -166,8 +166,6 @@ const products = lpProducts(learningPaths); const learningPaths = getLearningPaths(); - console.log(learningPaths); - if (!learningPaths) return; if (checkedAreas.length === 0 && checkedProducts.length === 0) { @@ -178,8 +176,6 @@ const products = lpProducts(learningPaths); } for (const learningPath of learningPaths) { - console.log(learningPath); - if (!learningPath.dataset.groups || !learningPath.dataset.products) continue; @@ -188,8 +184,6 @@ const products = lpProducts(learningPaths); let show = true; - console.log(show); - show = checkedAreas.some((v) => { return groups.includes(v); });