fixed redirects

This commit is contained in:
MCorange 2023-09-30 22:57:54 +03:00
parent 3b1a278665
commit 062a893460
No known key found for this signature in database
GPG Key ID: BFC3CC200C408BD7
2 changed files with 20 additions and 22 deletions

View File

@ -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 = () => {
<Route path="/social" component={Socials} />
<Route path="/about" component={About} />
<Route path="/donate" component={Donate} />
<Route path="/r">
{redirects.map((val)=>{
<Route path="/r/:id" component={Redirect}>
{/* {redirects.map((val)=>{
return (
<Route path={val.href} component={()=>{
window.location.assign(val.url);
return (<></>);
}}/>
)
})}
})} */}
</Route>
</Routes>
</div>

View File

@ -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
}
}
const params = useParams();
//@ts-ignore
const url = (redirects[params["id"] as string] || "/") as string;
redirect(url);
return (
<>
</>
);
<h1>Redirecting...</h1>
)
}