Skip to content

Commit

Permalink
Merge pull request #228 from acid-info/front-search
Browse files Browse the repository at this point in the history
Front search
  • Loading branch information
jeangovil authored Jan 22, 2024
2 parents 25727c9 + dd554fe commit 7a95262
Show file tree
Hide file tree
Showing 24 changed files with 681 additions and 179 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"feed": "^4.2.2",
"graphql": "^16.7.1",
"graphql-request": "^6.0.0",
"lunr": "^2.3.9",
"next": "13.3.0",
"next-query-params": "^4.2.3",
"nextjs-progressbar": "^0.0.16",
Expand All @@ -64,6 +65,7 @@
"slugify": "^1.6.6",
"typescript": "5.0.4",
"use-query-params": "^2.2.1",
"uuid": "^9.0.1",
"yup": "^1.3.2"
},
"devDependencies": {
Expand All @@ -73,7 +75,9 @@
"@graphql-codegen/typescript": "^4.0.1",
"@graphql-codegen/typescript-resolvers": "^4.0.1",
"@parcel/watcher": "^2.2.0",
"@types/lunr": "^2.3.7",
"@types/react-imgix": "^9.5.0",
"@types/uuid": "^9.0.7",
"dotenv-cli": "^7.2.1",
"husky": "^8.0.3",
"lint-staged": "^13.2.1",
Expand Down
3 changes: 1 addition & 2 deletions src/components/Episode/Footer/Episode.Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ const EpisodeFooter = ({ episode, relatedEpisodes }: Props) => {
return (
episode.content &&
episode.content
.filter((b) => (b as LPE.Post.TextBlock).footnotes.length)
.map((b) => (b as LPE.Post.TextBlock).footnotes)
.map((b) => (b as LPE.Post.TextBlock).footnotes || [])
.flat()
)
}, [episode])
Expand Down
6 changes: 5 additions & 1 deletion src/containers/ArticleContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ const ArticleContainer = (props: Props) => {
const [tocId, setTocId] = useState<string | null>(null)

return (
<PostSearchContainer postId={data.data.id} postTitle={data.data.title}>
<PostSearchContainer
postId={data.data.uuid}
postTitle={data.data.title}
blocks={props.data.data.content}
>
<PostSearchContext.Consumer>
{(search) => {
const displaySearchResults = search.active && !search.isInitialLoading
Expand Down
20 changes: 10 additions & 10 deletions src/containers/GlobalSearchBox/GlobalSearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ const contentTypes = [
value: PostTypes.Podcast,
category: ContentTypesCategories.Post,
},
{
label: 'Paragraphs',
value: ContentBlockTypes.Text,
category: ContentTypesCategories.Block,
},
{
label: 'Images',
value: ContentBlockTypes.Image,
category: ContentTypesCategories.Block,
},
// {
// label: 'Paragraphs',
// value: ContentBlockTypes.Text,
// category: ContentTypesCategories.Block,
// },
// {
// label: 'Images',
// value: ContentBlockTypes.Image,
// category: ContentTypesCategories.Block,
// },
]

const allContentTypes = contentTypes.map((c) => c.value)
Expand Down
1 change: 1 addition & 0 deletions src/containers/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export const HomePage: React.FC<HomePageProps> = ({
</Grid>
<AllPosts title="All posts">
<PostsGrid
shows={shows}
pattern={[{ cols: 4, size: 'small' }]}
breakpoints={[
{
Expand Down
5 changes: 4 additions & 1 deletion src/containers/PostSearchContainer/PostSearchContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import { SearchBox } from '../../components/SearchBox'
import { uiConfigs } from '../../configs/ui.configs'
import { usePostSearchQuery } from '../../queries/usePostSearch.query'
import { useNavbarState } from '../../states/navbarState'
import { LPE } from '../../types/lpe.types'
import { useOnWindowResize } from '../../utils/ui.utils'
import { PostSearchContext } from './PostSearch.context'

export type PostSearchContainerProps = {
postId?: string
postTitle?: string
blocks: LPE.Post.ContentBlock[]
}

export const PostSearchContainer: React.FC<
React.PropsWithChildren<PostSearchContainerProps>
> = ({ postId = '', postTitle, children, ...props }) => {
> = ({ postId = '', postTitle, blocks = [], children, ...props }) => {
const navbarState = useNavbarState()

const [prevQuery, setPrevQuery] = useState('')
Expand All @@ -27,6 +29,7 @@ export const PostSearchContainer: React.FC<
const res = usePostSearchQuery({
id: postId,
query,
blocks,
active: active && query.length > 0,
})

Expand Down
6 changes: 2 additions & 4 deletions src/containers/Search/ListView.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Grid, GridItem } from '@/components/Grid/Grid'
import { SearchResultListBlocks } from '@/components/Search/SearchResult.Blocks'
import { SearchResultTopPost } from '@/components/Search/SearchResult.TopPost'
import { SearchResultListPosts } from '@/components/Search/SearchResultList.Posts'
import { SearchResultsListHeader } from '@/components/Search/SearchResultsList.Header'
import { copyConfigs } from '@/configs/copy.configs'
import { uiConfigs } from '@/configs/ui.configs'
import { LPE } from '@/types/lpe.types'
Expand Down Expand Up @@ -138,7 +136,7 @@ export const SearchResultsListView = (props: Props) => {
</PostsListContent>
</PostsList>
<GridItem xs={{ cols: 0 }} md={{ cols: 1 }} cols={1} />
<BlocksList xs={{ cols: 8 }} md={{ cols: 3 }} lg={{ cols: 4 }} cols={4}>
{/* <BlocksList xs={{ cols: 8 }} md={{ cols: 3 }} lg={{ cols: 4 }} cols={4}>
{!isMobile && (
<BlockListSticky>
<SearchResultsListHeader
Expand All @@ -147,7 +145,7 @@ export const SearchResultsListView = (props: Props) => {
<SearchResultListBlocks blocks={renderBlocks} />
</BlockListSticky>
)}
</BlocksList>
</BlocksList> */}
</Container>
)
}
Expand Down
Loading

0 comments on commit 7a95262

Please sign in to comment.