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 Socials from './components/Socials';
|
||||||
import About from './components/About';
|
import About from './components/About';
|
||||||
import Donate from "./components/Donate"
|
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 = () => {
|
const App: Component = () => {
|
||||||
return (
|
return (
|
||||||
|
@ -26,15 +22,15 @@ const App: Component = () => {
|
||||||
<Route path="/social" component={Socials} />
|
<Route path="/social" component={Socials} />
|
||||||
<Route path="/about" component={About} />
|
<Route path="/about" component={About} />
|
||||||
<Route path="/donate" component={Donate} />
|
<Route path="/donate" component={Donate} />
|
||||||
<Route path="/r">
|
<Route path="/r/:id" component={Redirect}>
|
||||||
{redirects.map((val)=>{
|
{/* {redirects.map((val)=>{
|
||||||
return (
|
return (
|
||||||
<Route path={val.href} component={()=>{
|
<Route path={val.href} component={()=>{
|
||||||
window.location.assign(val.url);
|
window.location.assign(val.url);
|
||||||
return (<></>);
|
return (<></>);
|
||||||
}}/>
|
}}/>
|
||||||
)
|
)
|
||||||
})}
|
})} */}
|
||||||
</Route>
|
</Route>
|
||||||
</Routes>
|
</Routes>
|
||||||
</div>
|
</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 () => {
|
export default () => {
|
||||||
const p = window.location.pathname;
|
const params = useParams();
|
||||||
console.log(p);
|
//@ts-ignore
|
||||||
if (p.startsWith("/r")) {
|
const url = (redirects[params["id"] as string] || "/") as string;
|
||||||
switch (p) {
|
redirect(url);
|
||||||
case "/r/github":
|
|
||||||
redirect("https://github.com/MCorange99");
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<>
|
<h1>Redirecting...</h1>
|
||||||
</>
|
)
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user