From 8f69178e5ff3f53a9a3643f8adc647eebe5adea8 Mon Sep 17 00:00:00 2001 From: GauthierWebDev Date: Mon, 14 Apr 2025 05:38:54 +0200 Subject: [PATCH] feat: Improve navigation with subitems and getNeighboringLinks function --- app/components/syntax/PrevNextLinks.tsx | 49 +++++++----------------- app/data/certifications/dwwm/at2/page.md | 23 +++++++++++ 2 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 app/data/certifications/dwwm/at2/page.md diff --git a/app/components/syntax/PrevNextLinks.tsx b/app/components/syntax/PrevNextLinks.tsx index 6e9e7e6..271f130 100644 --- a/app/components/syntax/PrevNextLinks.tsx +++ b/app/components/syntax/PrevNextLinks.tsx @@ -52,49 +52,26 @@ function PageLink({ } export function PrevNextLinks() { - const allLinks = navigation.flatMap((section) => section.links); + const allLinks = navigation + .flatMap((section) => section.links) + .flatMap((link) => { + return link.subitems ? [link, ...link.subitems] : link; + }); const { urlPathname } = usePageContext(); - let subItemElement: undefined | NavigationSubItem; + const getNeighboringLinks = () => { + const linkIndex = allLinks.findIndex((link) => link.href === urlPathname); + if (linkIndex === -1) return [null, null]; - const findLinkIndex = (pathname = urlPathname) => { - for (let i = 0; i < allLinks.length; i++) { - const link = allLinks[i]; + const previousPage = allLinks[linkIndex - 1] || null; + const nextPage = allLinks[linkIndex + 1] || null; - if (link.href === urlPathname) { - return i; - } - - if (link.subitems) { - const subitemIndex = link.subitems.findIndex((subitem) => subitem.href === urlPathname); - - if (subitemIndex !== -1) { - subItemElement = link.subitems[subitemIndex]; - return i; - } - } - } + return [previousPage, nextPage]; }; - const linkIndex = findLinkIndex(); - if (linkIndex === undefined) return null; + const [previousPage, nextPage] = getNeighboringLinks(); - let previousPage: NavigationSubItem | NavigationLink | null = linkIndex > -1 ? allLinks[linkIndex - 1] : null; - let nextPage: NavigationSubItem | NavigationLink | null = linkIndex > -1 ? allLinks[linkIndex + 1] : null; - - if (subItemElement !== undefined) { - const subItemIndex = findLinkIndex(subItemElement.href)!; - const currentPage = allLinks[subItemIndex]; - const subItemIndexInLink = currentPage.subitems?.findIndex((subitem) => subitem.href === urlPathname); - if (subItemIndexInLink !== undefined && subItemIndexInLink > -1) { - previousPage = currentPage.subitems[subItemIndexInLink - 1]; - nextPage = currentPage.subitems[subItemIndexInLink + 1]; - } - } - - if (!nextPage && !previousPage) { - return null; - } + if (!nextPage && !previousPage) return null; return (
diff --git a/app/data/certifications/dwwm/at2/page.md b/app/data/certifications/dwwm/at2/page.md new file mode 100644 index 0000000..e3403c8 --- /dev/null +++ b/app/data/certifications/dwwm/at2/page.md @@ -0,0 +1,23 @@ +--- +title: Activité Type 2 - Développer la partie back-end d'une application web ou web mobile sécurisée +description: Synthèse et explications des attentes relatives à l'activité type 2 du titre professionnel DWWM (01280m04). +tags: [DWWM] +--- + +## 📚 Références + +- REAC _(mise à jour du 02/07/2024)_, pages 15 et 16 +- RE _(mise à jour du 02/07/2024)_, page 9 + +## 📋 En résumé + +Cette activité type concerne tout ce qui est relatif à la conception _(maquettes, arborescence etc.)_ et à la création de l'interface. + +Voyons un peu plus en détail ce qui est attendu pour chacune de ces compétences professionnelles ! 🚀 + +Elle est divisée en 4 **compétences professionnelles** _(CP)_ : + +- **CP 1** : Installer et configurer son environnement de travail en fonction du projet web ou web mobile +- **CP 2** : Maquetter des interfaces utilisateur web ou web mobile +- **CP 3** : Réaliser des interfaces utilisateur statiques web ou web mobile +- **CP 4** : Développer la partie dynamique des interfaces utilisateur web ou web mobile