Use basePath for internal links and export from next.config.ts

This commit is contained in:
2025-06-08 22:14:32 +02:00
parent 94b491a274
commit 162524e5b0
5 changed files with 17 additions and 12 deletions

View File

@@ -2,6 +2,7 @@ import "./globals.css";
import {Inter} from "next/font/google"; import {Inter} from "next/font/google";
import Navbar from "@/components/Navbar"; import Navbar from "@/components/Navbar";
import Footer from "@/components/Footer"; import Footer from "@/components/Footer";
import React from "react";
const inter = Inter({subsets: ["latin"]}); const inter = Inter({subsets: ["latin"]});
@@ -10,7 +11,8 @@ export const metadata = {
description: "Kompetente Rechtsberatung in allen Lebenslagen", description: "Kompetente Rechtsberatung in allen Lebenslagen",
}; };
export default function RootLayout({children}: { children: React.ReactNode }) { export default function RootLayout(
{children}: Readonly<{ children: React.ReactNode }>) {
return ( return (
<html lang="de"> <html lang="de">
<body className={inter.className}> <body className={inter.className}>

View File

@@ -4,6 +4,7 @@
import {motion} from 'framer-motion'; import {motion} from 'framer-motion';
import Link from 'next/link'; import Link from 'next/link';
import Image from 'next/image'; import Image from 'next/image';
import {basePath} from '@/next.config';
export default function HomePage() { export default function HomePage() {
return ( return (
@@ -29,7 +30,7 @@ export default function HomePage() {
<p className="text-lg max-w-2xl text-gray-100"> <p className="text-lg max-w-2xl text-gray-100">
Persönliche Betreuung. Klare Kommunikation. Effektive Lösungen für Ihr Anliegen. Persönliche Betreuung. Klare Kommunikation. Effektive Lösungen für Ihr Anliegen.
</p> </p>
<Link href="/kontakt/"> <Link href={`${basePath}/kontakt/`}>
<motion.button <motion.button
whileHover={{scale: 1.05}} whileHover={{scale: 1.05}}
whileTap={{scale: 0.95}} whileTap={{scale: 0.95}}

View File

@@ -1,4 +1,5 @@
import Link from 'next/link'; import Link from 'next/link';
import {basePath} from "@/next.config";
export default function Footer() { export default function Footer() {
return ( return (
@@ -9,10 +10,10 @@ export default function Footer() {
<p>&copy; {new Date().getFullYear()} Kanzlei Mustermann. Alle Rechte vorbehalten.</p> <p>&copy; {new Date().getFullYear()} Kanzlei Mustermann. Alle Rechte vorbehalten.</p>
</div> </div>
<div className="space-x-4"> <div className="space-x-4">
<Link href="/impressum/" className="hover:underline">Impressum</Link> <Link href={`${basePath}/impressum/`} className="hover:underline">Impressum</Link>
<Link href="/datenschutz/" className="hover:underline">Datenschutz</Link> <Link href={`${basePath}/datenschutz/`} className="hover:underline">Datenschutz</Link>
</div> </div>
</div> </div>
</footer> </footer>
); );
} }

View File

@@ -2,6 +2,7 @@
import Link from 'next/link'; import Link from 'next/link';
import {motion} from 'framer-motion'; import {motion} from 'framer-motion';
import {basePath} from "@/next.config";
export default function Navbar() { export default function Navbar() {
return ( return (
@@ -12,14 +13,14 @@ export default function Navbar() {
className="fixed top-0 left-0 right-0 z-50 bg-white shadow-md py-4 px-6 md:px-12 lg:px-24 text-gray-900" className="fixed top-0 left-0 right-0 z-50 bg-white shadow-md py-4 px-6 md:px-12 lg:px-24 text-gray-900"
> >
<div className="flex justify-between items-center"> <div className="flex justify-between items-center">
<Link href="/"> <Link href={`${basePath}/`}>
<span className="text-xl font-bold text-blue-800">Kanzlei Mustermann</span> <span className="text-xl font-bold text-blue-800">Kanzlei Mustermann</span>
</Link> </Link>
<div className="space-x-6 text-sm md:text-base"> <div className="space-x-6 text-sm md:text-base">
<Link href="/">Start</Link> <Link href={`${basePath}/`}>Start</Link>
<Link href="/ueber-uns/">Über uns</Link> <Link href={`${basePath}/ueber-uns/`}>Über uns</Link>
<Link href="/impressum/">Impressum</Link> <Link href={`${basePath}/impressum/`}>Impressum</Link>
<Link href="/datenschutz/">Datenschutz</Link> <Link href={`${basePath}/datenschutz/`}>Datenschutz</Link>
</div> </div>
</div> </div>
</motion.nav> </motion.nav>

View File

@@ -2,8 +2,8 @@ import type {NextConfig} from "next";
const isProd = process.env.NODE_ENV === 'production'; const isProd = process.env.NODE_ENV === 'production';
const basePath = isProd ? '/lawfirm/demo1' : ''; export const basePath = isProd ? '/lawfirm/demo1' : '';
const assetPrefix = isProd ? '/lawfirm/demo1' : ''; export const assetPrefix = isProd ? '/lawfirm/demo1' : '';
console.log(`🚀 [next.config.ts] Running in ${process.env.NODE_ENV} mode`); console.log(`🚀 [next.config.ts] Running in ${process.env.NODE_ENV} mode`);
console.log(`👉 basePath: ${basePath || '(none)'}`); console.log(`👉 basePath: ${basePath || '(none)'}`);