Skip to content

Commit

Permalink
fix: subpath removal
Browse files Browse the repository at this point in the history
  • Loading branch information
lsegg committed Oct 24, 2024
1 parent f53c1ce commit 2e89ef7
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 32 deletions.
22 changes: 11 additions & 11 deletions docs/assets/index-VBkLQ-qs.js → docs/assets/index-C8kJS1VA.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"
/>
<script type="module" crossorigin src="./assets/index-VBkLQ-qs.js"></script>
<script type="module" crossorigin src="./assets/index-C8kJS1VA.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DgD5xdTU.css" />
</head>
<body>
Expand Down
3 changes: 1 addition & 2 deletions src/auth/pages/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export const LoginPage = () => {
const navigate = useNavigate();

const handleLogin = () => {
const lastPath =
localStorage.getItem("lastPath") || "/heroes-spa/home/search";
const lastPath = localStorage.getItem("lastPath") || "/home/search";
login("Jane Doe");
navigate(lastPath, { replace: true });
};
Expand Down
5 changes: 1 addition & 4 deletions src/heroes/components/HeroCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ export const HeroCard = ({
<p className="card-text">
<small className="text-muted">{first_appearance}</small>
</p>
<Link
to={`/heroes-spa/home/hero/${id}`}
className="btn btn-outline-dark"
>
<Link to={`/home/hero/${id}`} className="btn btn-outline-dark">
More info
</Link>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/heroes/pages/HeroPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const HeroPage = () => {
navigate(-1);
};

if (!hero) return <Navigate to="/heroes-spa/home" />;
if (!hero) return <Navigate to="/home" />;
return (
<div className="row mt-5">
<div className="col-4">
Expand Down
12 changes: 6 additions & 6 deletions src/router/AppRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PublicRouter } from "./PublicRouter";

const router = createHashRouter([
{
path: "/heroes-spa",
path: "/",
element: (
<PublicRouter>
<LoginPage />
Expand All @@ -17,7 +17,7 @@ const router = createHashRouter([
errorElement: <ErrorPage />,
},
{
path: "/heroes-spa/home",
path: "home",
element: (
<PrivateRouter>
<HeroesApp />
Expand All @@ -26,19 +26,19 @@ const router = createHashRouter([
errorElement: <ErrorPage />,
children: [
{
path: "/heroes-spa/home/marvel",
path: "marvel",
element: <MarvelPage />,
},
{
path: "/heroes-spa/home/dc",
path: "dc",
element: <DcPage />,
},
{
path: "/heroes-spa/home/search",
path: "search",
element: <SearchPage />,
},
{
path: "/heroes-spa/home/hero/:id",
path: "hero/:id",
element: <HeroPage />,
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/router/PrivateRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ export const PrivateRouter = ({ children }) => {
const lastPath = pathname + search;
localStorage.setItem("lastPath", lastPath);

return logged ? children : <Navigate to={"/heroes-spa/login"} />;
return logged ? children : <Navigate to={"/login"} />;
};
2 changes: 1 addition & 1 deletion src/router/PublicRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { AuthContext } from "../auth";

export const PublicRouter = ({ children }) => {
const { logged } = useContext(AuthContext);
return !logged ? children : <Navigate to={"/heroes-spa/home/search"} />;
return !logged ? children : <Navigate to={"/home/search"} />;
};
10 changes: 5 additions & 5 deletions src/ui/components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export const NavBar = () => {
const navigate = useNavigate();
const handleLogout = () => {
logout();
navigate("/heroes-spa", { replace: true });
navigate("/", { replace: true });
};

return (
<nav className="navbar navbar-expand-lg navbar-dark bg-dark p-2">
<div className="container-fluid">
<Link className="navbar-brand" to="/heroes-spa/home/search">
<Link className="navbar-brand" to="/home/search">
Heroes
</Link>
<div className="collapse navbar-collapse" id="navbarNav">
Expand All @@ -22,23 +22,23 @@ export const NavBar = () => {
className={({ isActive }) =>
`nav-link ${isActive ? "active" : ""}`
}
to="/heroes-spa/home/marvel"
to="marvel"
>
Marvel
</NavLink>
<NavLink
className={({ isActive }) =>
`nav-link ${isActive ? "active" : ""}`
}
to="/heroes-spa/home/dc"
to="/home/dc"
>
DC
</NavLink>
<NavLink
className={({ isActive }) =>
`nav-link ${isActive ? "active" : ""}`
}
to="/heroes-spa/home/search"
to="/home/search"
>
Search
</NavLink>
Expand Down

0 comments on commit 2e89ef7

Please sign in to comment.