Pfad-Problem behoben. Hoffe ich...
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 9s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 9s
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
const startYear = 2026;
|
const startYear = 2026;
|
||||||
const displayYear = currentYear > startYear ? `${startYear}–${currentYear}` : startYear;
|
const displayYear = currentYear > startYear ? `${startYear}–${currentYear}` : startYear;
|
||||||
|
import { getPath } from '../utils/paths';
|
||||||
---
|
---
|
||||||
|
|
||||||
<footer class="main-footer">
|
<footer class="main-footer">
|
||||||
@@ -13,8 +14,8 @@ const displayYear = currentYear > startYear ? `${startYear}–${currentYear}` :
|
|||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="footer-links">
|
<ul class="footer-links">
|
||||||
<li><a href="/impressum" class="footer-link-item">Impressum</a></li>
|
<li><a href={getPath("/impressum")} class="footer-link-item">Impressum</a></li>
|
||||||
<li><a href="/datenschutz" class="footer-link-item">Datenschutz</a></li>
|
<li><a href={getPath("/datenschutz")} class="footer-link-item">Datenschutz</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
---
|
---
|
||||||
// src/components/Header.astro
|
|
||||||
import Logo from './Logo.astro';
|
import Logo from './Logo.astro';
|
||||||
|
|
||||||
// Optional: Logik um den aktiven Link zu erkennen
|
|
||||||
const pathname = new URL(Astro.request.url).pathname;
|
const pathname = new URL(Astro.request.url).pathname;
|
||||||
const currentPath = pathname.slice(1);
|
const currentPath = pathname.slice(1);
|
||||||
---
|
---
|
||||||
|
|||||||
18
src/utils/paths.ts
Normal file
18
src/utils/paths.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// src/utils/paths.ts
|
||||||
|
|
||||||
|
// Wir greifen auf die Umgebungsvariable von Astro zu
|
||||||
|
const base = import.meta.env.BASE_URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erstellt einen korrekten Pfad unter Berücksichtigung der Astro 'base' Konfiguration.
|
||||||
|
* Verhindert doppelte Slashes und funktioniert in Dev, Test und Prod.
|
||||||
|
*/
|
||||||
|
export function getPath(path: string): string {
|
||||||
|
// Entfernt den Slash am Ende der Base, falls vorhanden
|
||||||
|
const normalizedBase = base.replace(/\/$/, '');
|
||||||
|
|
||||||
|
// Stellt sicher, dass der Pfad mit einem Slash beginnt
|
||||||
|
const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
||||||
|
|
||||||
|
return `${normalizedBase}${normalizedPath}`;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user