Browse Source

refactor: update route paths

imwald
codytseng 1 year ago
parent
commit
5dd3908db1
  1. 10
      src/renderer/src/lib/link.ts
  2. 10
      src/renderer/src/routes.tsx

10
src/renderer/src/lib/link.ts

@ -1,5 +1,5 @@
export const toHome = () => '/' export const toHome = () => '/'
export const toNote = (eventId: string) => `/note/${eventId}` export const toNote = (eventId: string) => `/notes/${eventId}`
export const toNoteList = ({ export const toNoteList = ({
hashtag, hashtag,
search, search,
@ -9,21 +9,21 @@ export const toNoteList = ({
search?: string search?: string
relay?: string relay?: string
}) => { }) => {
const path = '/note' const path = '/notes'
const query = new URLSearchParams() const query = new URLSearchParams()
if (hashtag) query.set('t', hashtag.toLowerCase()) if (hashtag) query.set('t', hashtag.toLowerCase())
if (search) query.set('s', search) if (search) query.set('s', search)
if (relay) query.set('relay', relay) if (relay) query.set('relay', relay)
return `${path}?${query.toString()}` return `${path}?${query.toString()}`
} }
export const toProfile = (pubkey: string) => `/user/${pubkey}` export const toProfile = (pubkey: string) => `/users/${pubkey}`
export const toProfileList = ({ search }: { search?: string }) => { export const toProfileList = ({ search }: { search?: string }) => {
const path = '/user' const path = '/users'
const query = new URLSearchParams() const query = new URLSearchParams()
if (search) query.set('s', search) if (search) query.set('s', search)
return `${path}?${query.toString()}` return `${path}?${query.toString()}`
} }
export const toFollowingList = (pubkey: string) => `/user/${pubkey}/following` export const toFollowingList = (pubkey: string) => `/users/${pubkey}/following`
export const toRelaySettings = () => '/relay-settings' export const toRelaySettings = () => '/relay-settings'
export const toNoStrudelProfile = (id: string) => `https://nostrudel.ninja/#/u/${id}` export const toNoStrudelProfile = (id: string) => `https://nostrudel.ninja/#/u/${id}`

10
src/renderer/src/routes.tsx

@ -10,11 +10,11 @@ import RelaySettingsPage from './pages/secondary/RelaySettingsPage'
const ROUTES = [ const ROUTES = [
{ path: '/', element: <HomePage /> }, { path: '/', element: <HomePage /> },
{ path: '/note', element: <NoteListPage /> }, { path: '/notes', element: <NoteListPage /> },
{ path: '/note/:id', element: <NotePage /> }, { path: '/notes/:id', element: <NotePage /> },
{ path: '/user', element: <ProfileListPage /> }, { path: '/users', element: <ProfileListPage /> },
{ path: '/user/:id', element: <ProfilePage /> }, { path: '/users/:id', element: <ProfilePage /> },
{ path: '/user/:id/following', element: <FollowingListPage /> }, { path: '/users/:id/following', element: <FollowingListPage /> },
{ path: '/relay-settings', element: <RelaySettingsPage /> } { path: '/relay-settings', element: <RelaySettingsPage /> }
] ]

Loading…
Cancel
Save