Skip to content

Commit

Permalink
🐛 use search param hook to ensure that client side search is triggered (
Browse files Browse the repository at this point in the history
  • Loading branch information
foysalit authored Oct 2, 2024
1 parent f3faf0e commit 147b3f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
17 changes: 8 additions & 9 deletions app/search/page-content.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ActionButton } from '@/common/buttons'
import { Dropdown } from '@/common/Dropdown'
import { Loading } from '@/common/Loader'
import { LoadMoreButton } from '@/common/LoadMoreButton'
import { ConfirmationModal } from '@/common/modals/confirmation'
import { PostAsCard } from '@/common/posts/PostsFeed'
import { useWorkspaceOpener } from '@/common/useWorkspaceOpener'
import { WorkspacePanel } from '@/workspace/Panel'
import { useContentSearch } from 'components/search-content/useContentSearch'
import { SectionHeader } from 'components/SectionHeader'
import { useSearchParams } from 'next/navigation'
import { useTitle } from 'react-use'

const TABS = [
Expand All @@ -22,13 +22,11 @@ const TABS = [
},
]

export const SearchPageContent = ({
term,
section = 'top',
}: {
term: string
section?: string
}) => {
export const SearchPageContent = () => {
const searchParams = useSearchParams()
const term = searchParams.get('term') ?? ''
const section = searchParams.get('section') ?? 'top'

let pageTitle = `Search Content`
if (term) {
pageTitle += ` - ${term}`
Expand Down Expand Up @@ -70,6 +68,7 @@ export const SearchPageContent = ({
</SectionHeader>

<div className="w-5/6 sm:w-3/4 md:w-2/3 lg:w-1/2 mx-auto my-4 dark:text-gray-100">
{isLoading && <Loading />}
{posts.map((post) => (
<div className="mb-4" key={post.uri}>
<PostAsCard
Expand Down
7 changes: 2 additions & 5 deletions app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
import { Suspense } from 'react'
import { SearchPageContent } from './page-content'

export default function SearchHomePage({ searchParams }) {
export default function SearchHomePage() {
return (
<Suspense fallback={<div></div>}>
<SearchPageContent
term={searchParams.term || ''}
section={searchParams.section}
/>
<SearchPageContent />
</Suspense>
)
}

0 comments on commit 147b3f2

Please sign in to comment.