fixed redirects
This commit is contained in:
parent
3b1a278665
commit
062a893460
12
src/App.tsx
12
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 = () => {
|
|||
<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>
|
||||
|
|
|
@ -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>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user