Navigation als Single Page Application
This commit is contained in:
@@ -13,8 +13,7 @@ function Navigation() {
|
|||||||
}
|
}
|
||||||
}, [pathname]);
|
}, [pathname]);
|
||||||
|
|
||||||
// Dynamische Anpassung der Pfade mit oder ohne .html
|
// Menüeinträge ohne .html-Endungen für SPA-Navigation
|
||||||
const isProduction = process.env.NEXT_PUBLIC_NODE_ENV === "production";
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{ name: "Übersicht", path: "/dashboard" },
|
{ name: "Übersicht", path: "/dashboard" },
|
||||||
{ name: "Kabelüberwachung", path: "/kabelueberwachung" },
|
{ name: "Kabelüberwachung", path: "/kabelueberwachung" },
|
||||||
@@ -25,14 +24,10 @@ function Navigation() {
|
|||||||
<aside>
|
<aside>
|
||||||
<nav className="w-64 flex-shrink-0 mt-32 overflow-hidden">
|
<nav className="w-64 flex-shrink-0 mt-32 overflow-hidden">
|
||||||
{menuItems.map((item) => (
|
{menuItems.map((item) => (
|
||||||
<Link
|
<Link href={item.path} key={item.name}>
|
||||||
href={`${item.path}${isProduction ? ".html" : ""}`}
|
|
||||||
key={item.name}
|
|
||||||
>
|
|
||||||
<div
|
<div
|
||||||
className={`block px-4 py-2 mb-4 font-bold whitespace-nowrap transition duration-300 ${
|
className={`block px-4 py-2 mb-4 font-bold whitespace-nowrap transition duration-300 ${
|
||||||
activeLink.startsWith(item.path) ||
|
activeLink.startsWith(item.path)
|
||||||
activeLink.startsWith(item.path + ".html")
|
|
||||||
? "bg-sky-500 text-white rounded-r-full"
|
? "bg-sky-500 text-white rounded-r-full"
|
||||||
: "text-black hover:bg-gray-200 rounded-r-full"
|
: "text-black hover:bg-gray-200 rounded-r-full"
|
||||||
}`}
|
}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user