有没有办法防止rootlayout
被包裹在dashboardlayout
周围?Next.js v13
文档:
我的文件 struct :
我可以使用route groups;但是,这样做将禁用我的contact
,pricing
路由中的包装.有没有办法防止这种情况发生?我想在联系和定价页面上的主页导航栏,但不想在我的仪表板主页导航栏.
我try 使用路由组;然而,它禁用了我的定价和联系路由中的包装.
navbar.tsx
个
"use client";
import Link from "next/link";
import Image from "next/image";
import { useEffect, useState } from "react";
import { Disclosure } from "@headlessui/react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faBars, faTimes } from "@fortawesome/free-solid-svg-icons";
function joinClassName(...classes: string[]) {
return classes.filter(Boolean).join(" ");
}
const navigationList = [
{
title: "API",
href: "/api",
},
{ title: "Pricing", href: "/pricing" },
{ title: "Contact", href: "/contact" },
{ title: "Demo", href: "/demo" },
];
export default function Navbar() {
const [navbar, setNavbar] = useState(false);
const changeBackground = () => {
if (window.scrollY >= 64) {
setNavbar(true);
} else {
setNavbar(false);
}
};
useEffect(() => {
changeBackground();
window.addEventListener("scroll", changeBackground);
});
return (
<Disclosure as="nav">
{({ open, close }) => (
<>
<div
className={joinClassName(
navbar || open ? "dark:bg-black bg-white" : "bg-transparent",
" fixed top-0 left-0 right-0 z-50 "
)}
>
</div>
</>
)}
</Disclosure>
);
}