refactor: Remove unnecessary code imports and rearrange variable declarations
This commit is contained in:
parent
8f69178e5f
commit
52c964b388
@ -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 (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user