feat: Improve navigation with subitems and getNeighboringLinks function
This commit is contained in:
parent
0e0c56cdcf
commit
8f69178e5f
@ -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 (
|
||||
<dl className="mt-12 flex border-t border-slate-200 pt-6 dark:border-slate-800">
|
||||
|
||||
23
app/data/certifications/dwwm/at2/page.md
Normal file
23
app/data/certifications/dwwm/at2/page.md
Normal file
@ -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
|
||||
Loading…
Reference in New Issue
Block a user