refactor: Remove unnecessary code imports and rearrange variable declarations

This commit is contained in:
Gauthier Daniels 2025-04-14 05:39:52 +02:00
parent 8f69178e5f
commit 52c964b388

View File

@ -1,6 +1,6 @@
import { navigation, NavigationLink, type NavigationSubItem } from "@/lib/navigation";
import { usePageContext } from "vike-react/usePageContext"; import { usePageContext } from "vike-react/usePageContext";
import { Link } from "@/components/common/Link"; import { Link } from "@/components/common/Link";
import { navigation } from "@/lib/navigation";
import clsx from "clsx"; import clsx from "clsx";
function ArrowIcon(props: React.ComponentPropsWithoutRef<"svg">) { function ArrowIcon(props: React.ComponentPropsWithoutRef<"svg">) {
@ -52,12 +52,13 @@ function PageLink({
} }
export function PrevNextLinks() { export function PrevNextLinks() {
const { urlPathname } = usePageContext();
const allLinks = navigation const allLinks = navigation
.flatMap((section) => section.links) .flatMap((section) => section.links)
.flatMap((link) => { .flatMap((link) => {
return link.subitems ? [link, ...link.subitems] : link; return link.subitems ? [link, ...link.subitems] : link;
}); });
const { urlPathname } = usePageContext();
const getNeighboringLinks = () => { const getNeighboringLinks = () => {
const linkIndex = allLinks.findIndex((link) => link.href === urlPathname); const linkIndex = allLinks.findIndex((link) => link.href === urlPathname);
@ -70,7 +71,6 @@ export function PrevNextLinks() {
}; };
const [previousPage, nextPage] = getNeighboringLinks(); const [previousPage, nextPage] = getNeighboringLinks();
if (!nextPage && !previousPage) return null; if (!nextPage && !previousPage) return null;
return ( return (