From 062a89346045396421b5b0a412b9a17d36258769 Mon Sep 17 00:00:00 2001 From: MCorange Date: Sat, 30 Sep 2023 22:57:54 +0300 Subject: [PATCH] fixed redirects --- src/App.tsx | 12 ++++-------- src/components/Redirect.tsx | 30 ++++++++++++++++-------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 7743256..97b3739 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,12 +7,8 @@ import Blog from './components/Blog'; import Socials from './components/Socials'; import About from './components/About'; import Donate from "./components/Donate" +import Redirect from './components/Redirect'; -const redirects = [ - {href: "/github", url: "https://github.com/MCorange99"}, - {href: "/ko-fi", url: "https://ko-fi.com/mcorange"}, - {href: "/mastadon", url: "https://river.group.lt/@mcorange"} -] const App: Component = () => { return ( @@ -26,15 +22,15 @@ const App: Component = () => { - - {redirects.map((val)=>{ + + {/* {redirects.map((val)=>{ return ( { window.location.assign(val.url); return (<>); }}/> ) - })} + })} */} diff --git a/src/components/Redirect.tsx b/src/components/Redirect.tsx index f0c88c8..2d3602d 100644 --- a/src/components/Redirect.tsx +++ b/src/components/Redirect.tsx @@ -1,20 +1,22 @@ -import { Route, Router, Routes } from "@solidjs/router"; +import { Route, Router, Routes, useParams } from "@solidjs/router"; + +const redirects = { + "github": "https://github.com/MCorange99", + "ko-fi": "https://ko-fi.com/mcorange", + "mastadon": "https://river.group.lt/@mcorange", +}; export default () => { - const p = window.location.pathname; - console.log(p); - if (p.startsWith("/r")) { - switch (p) { - case "/r/github": - redirect("https://github.com/MCorange99"); - break - } - } - return ( - <> - - ); + const params = useParams(); + //@ts-ignore + const url = (redirects[params["id"] as string] || "/") as string; + redirect(url); + + return ( +

Redirecting...

+ ) + }