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";
}) {
return (
{dir === "next" ? "Suivant" : "Précédent"}
{title}
);
}
export function PrevNextLinks() {
let { urlPathname } = usePageContext();
let allLinks = navigation.flatMap((section) => section.links);
let linkIndex = allLinks.findIndex((link) => link.href === urlPathname);
let previousPage = linkIndex > -1 ? allLinks[linkIndex - 1] : null;
let nextPage = linkIndex > -1 ? allLinks[linkIndex + 1] : null;
if (!nextPage && !previousPage) {
return null;
}
return (
{previousPage && }
{nextPage && }
);
}