Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 4 additions & 27 deletions web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import React from "react";
import {
BrowserRouter,
Routes,
Route,
Navigate,
useSearchParams,
} from "react-router-dom";
import { BrowserRouter, Routes, Route, Navigate } from "react-router-dom";
import { initAuth } from "./store/auth";
import { loadPreferences } from "./store/preferences";

Expand All @@ -23,21 +17,12 @@ import {
CollectionDetailWrapper,
AnnotationDetailWrapper,
UserUrlWrapper,
SiteWrapper,
UrlWrapper,
} from "./routes/wrappers";
import About from "./views/About";
import AdminModeration from "./views/core/AdminModeration";
import NotFound from "./views/NotFound";

function UrlRedirect() {
const [searchParams] = useSearchParams();
const q = searchParams.get("q");
if (q) {
return <Navigate to={`/site/${encodeURIComponent(q)}`} replace />;
}
return <Navigate to="/site" replace />;
}

export default function App() {
React.useEffect(() => {
initAuth();
Expand Down Expand Up @@ -144,14 +129,6 @@ export default function App() {
}
/>

<Route
path="/url"
element={
<AppLayout>
<UrlRedirect />
</AppLayout>
}
/>
<Route
path="/new"
element={
Expand Down Expand Up @@ -209,10 +186,10 @@ export default function App() {
}
/>
<Route
path="/site/*"
path="/url/*"
element={
<AppLayout>
<SiteWrapper />
<UrlWrapper />
</AppLayout>
}
/>
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/navigation/MobileNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ export default function MobileNav() {
</Link>

<Link
to="/site"
to="/url"
className={`flex flex-col items-center justify-center w-14 h-14 rounded-xl transition-colors ${
isActive("/site")
isActive("/url")
? "text-primary-600"
: "text-surface-500 hover:text-surface-700"
}`}
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/navigation/RightSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function RightSidebar() {

const handleSearch = (e: React.KeyboardEvent) => {
if (e.key === "Enter" && searchQuery.trim()) {
navigate(`/site/${encodeURIComponent(searchQuery.trim())}`);
navigate(`/url/${encodeURIComponent(searchQuery.trim())}`);
}
};

Expand Down
12 changes: 6 additions & 6 deletions web/src/routes/wrappers.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useStore } from "@nanostores/react";
import React from "react";
import { Navigate, useParams } from "react-router-dom";
import { useStore } from "@nanostores/react";
import { $user } from "../store/auth";
import Profile from "../views/profile/Profile";
import CollectionDetail from "../views/collections/CollectionDetail";
import AnnotationDetail from "../views/content/AnnotationDetail";
import UserUrlPage from "../views/content/UserUrl";
import SitePage from "../views/content/SitePage";
import UrlPage from "../views/content/UrlPage";
import UserUrlPage from "../views/content/UserUrlPage";
import Profile from "../views/profile/Profile";

export function ProfileWrapper() {
const { did } = useParams();
Expand All @@ -33,6 +33,6 @@ export function UserUrlWrapper() {
return <UserUrlPage />;
}

export function SiteWrapper() {
return <SitePage />;
export function UrlWrapper() {
return <UrlPage />;
}
Loading