import { usePageContext } from "vike-react/usePageContext"; import { Link } from "@/components/common/Link"; import clsx from "clsx"; import { navigation } from "@/lib/navigation"; function ArrowIcon(props: React.ComponentPropsWithoutRef<"svg">) { return ( ); } function PageLink({ title, href, dir = "next", ...props }: Omit, "dir" | "title"> & { title: string; href: string; dir?: "previous" | "next"; }) { const pageCategory = navigation.find((section) => { return section.links.some((link) => link.href === href); })!; return (
{dir === "next" ? "Suivant" : "Précédent"}

{pageCategory.title} {title}

); } export function PrevNextLinks() { const { urlPathname } = usePageContext(); const allLinks = navigation.flatMap((section) => section.links); const linkIndex = allLinks.findIndex((link) => link.href === urlPathname); const previousPage = linkIndex > -1 ? allLinks[linkIndex - 1] : null; const nextPage = linkIndex > -1 ? allLinks[linkIndex + 1] : null; if (!nextPage && !previousPage) { return null; } return (
{previousPage && } {nextPage && }
); }