From d9f808d4197d5d53d57d2bf66e9d5d4ba95ae30b Mon Sep 17 00:00:00 2001 From: Bram Suurd <78373894+BramSuurdje@users.noreply.github.com> Date: Fri, 8 Nov 2024 14:04:07 +0100 Subject: [PATCH] Enhance URL handling in RootLayout for consistent redirect to new Proxmox site --- src/app/layout.tsx | 53 ++++++++-------------------------------------- 1 file changed, 9 insertions(+), 44 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index a8c951b..c89d373 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -5,57 +5,22 @@ import React, { useEffect } from "react"; const inter = Inter({ subsets: ["latin"] }); -// export const metadata = { -// title: "Proxmox VE Helper-Scripts", -// generator: "Next.js", -// applicationName: "Proxmox VE Helper-Scripts", -// referrer: "origin-when-cross-origin", -// keywords: [ -// "Proxmox VE", -// "Helper-Scripts", -// "tteck", -// "helper", -// "scripts", -// "proxmox", -// "VE", -// ], -// authors: { name: "Bram Suurd" }, -// creator: "Bram Suurd", -// publisher: "Bram Suurd", -// description: -// "A Front-end for the Proxmox VE Helper-Scripts (Community) Repository. Featuring over 200+ scripts to help you manage your Proxmox VE environment.", -// favicon: "/app/favicon.ico", -// formatDetection: { -// email: false, -// address: false, -// telephone: false, -// }, -// metadataBase: new URL("https://community-scripts.github.io/Proxmox/"), -// openGraph: { -// title: "Proxmox VE Helper-Scripts", -// description: -// "A Front-end for the Proxmox VE Helper-Scripts (Community) Repository. Featuring over 200+ scripts to help you manage your Proxmox VE environment.", -// url: "/defaultimg.png", -// images: [ -// { -// url: "https://community-scripts.github.io/Proxmox/defaultimg.png", -// }, -// ], export default function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { - useEffect(() => { - const originalUrl = window.location.pathname; - const newBaseUrl = "https://community-scripts.github.io/ProxmoxVE"; +useEffect(() => { + const originalUrl = + window.location.pathname + window.location.search + window.location.hash; + const newBaseUrl = "https://community-scripts.github.io/ProxmoxVE"; - const newUrl = originalUrl.replace(/^\/Proxmox/, newBaseUrl) || "/"; + const newUrl = originalUrl.replace(/^\/Proxmox/, newBaseUrl) || "/"; - if (newUrl !== window.location.href) { - window.location.href = newUrl; - } - }, []); + if (newUrl !== window.location.href) { + window.location.href = newUrl; + } +}, []); return (