add dynamic filters to search page
This commit is contained in:
parent
a448d52fce
commit
62826ec552
|
@ -4,16 +4,8 @@ import styled from '@emotion/styled'
|
||||||
export default function Hero() {
|
export default function Hero() {
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<Title genericFontFamily="serif" component="span" variant="h2">
|
<Title genericFontFamily="serif" component="h1" variant="h1">
|
||||||
LOGOS →{' '}
|
LOGOS → PRESS ENGINE
|
||||||
<Title
|
|
||||||
style={{ whiteSpace: 'nowrap' }}
|
|
||||||
genericFontFamily="serif"
|
|
||||||
component="span"
|
|
||||||
variant="h2"
|
|
||||||
>
|
|
||||||
PRESS ENGINE
|
|
||||||
</Title>
|
|
||||||
</Title>
|
</Title>
|
||||||
<Description component="div" variant="label2">
|
<Description component="div" variant="label2">
|
||||||
Blog with media written by Logos members
|
Blog with media written by Logos members
|
||||||
|
|
|
@ -34,7 +34,7 @@ export type SearchbarProps = {
|
||||||
|
|
||||||
export default function Searchbar(props: SearchbarProps) {
|
export default function Searchbar(props: SearchbarProps) {
|
||||||
const { onSearch, onReset } = props
|
const { onSearch, onReset } = props
|
||||||
const { resultsNumber, resultsHelperText } = useSearchBarContext()
|
const { resultsNumber, resultsHelperText, tags } = useSearchBarContext()
|
||||||
|
|
||||||
const [searchScope, setSearchScope] = useState<ESearchScope>(
|
const [searchScope, setSearchScope] = useState<ESearchScope>(
|
||||||
props.searchScope || ESearchScope.GLOBAL,
|
props.searchScope || ESearchScope.GLOBAL,
|
||||||
|
@ -178,7 +178,7 @@ export default function Searchbar(props: SearchbarProps) {
|
||||||
{!isArticlePage && (
|
{!isArticlePage && (
|
||||||
<TagsWrapper className={active ? 'active' : ''}>
|
<TagsWrapper className={active ? 'active' : ''}>
|
||||||
<FilterTags
|
<FilterTags
|
||||||
tags={copyConfigs.search.filterTags}
|
tags={tags}
|
||||||
onTagClick={handleTagClick}
|
onTagClick={handleTagClick}
|
||||||
selectedTags={filterTags}
|
selectedTags={filterTags}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -17,20 +17,28 @@ import { SearchLayout } from '@/layouts/SearchLayout'
|
||||||
import { RelatedArticles } from '@/components/RelatedArticles'
|
import { RelatedArticles } from '@/components/RelatedArticles'
|
||||||
import { RelatedContent } from '@/components/RelatedContent'
|
import { RelatedContent } from '@/components/RelatedContent'
|
||||||
import { Section } from '@/components/Section/Section'
|
import { Section } from '@/components/Section/Section'
|
||||||
|
import api from '@/services/unbody.service'
|
||||||
|
import { useSearchBarContext } from '@/context/searchbar.context'
|
||||||
|
|
||||||
interface SearchPageProps {
|
interface SearchPageProps {
|
||||||
articles: SearchResultItem<UnbodyGoogleDoc>[]
|
articles: SearchResultItem<UnbodyGoogleDoc>[]
|
||||||
blocks: SearchResultItem<UnbodyTextBlock | UnbodyImageBlock>[]
|
blocks: SearchResultItem<UnbodyTextBlock | UnbodyImageBlock>[]
|
||||||
|
topics: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SearchPage({
|
export default function SearchPage({
|
||||||
articles: initialArticles = [],
|
articles: initialArticles = [],
|
||||||
blocks: initialBlocks = [],
|
blocks: initialBlocks = [],
|
||||||
|
topics: allTopics = [],
|
||||||
}: SearchPageProps) {
|
}: SearchPageProps) {
|
||||||
|
const { setTags } = useSearchBarContext()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const hasUpdated = useRef(false)
|
|
||||||
const [mounted, setMounted] = useState(false)
|
const [mounted, setMounted] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setTags(allTopics)
|
||||||
|
}, [setTags, allTopics])
|
||||||
|
|
||||||
const {
|
const {
|
||||||
query: { query = '', topics = [] },
|
query: { query = '', topics = [] },
|
||||||
} = router
|
} = router
|
||||||
|
@ -81,11 +89,13 @@ SearchPage.getLayout = function getLayout(page: ReactNode) {
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
const { data: articles = [] } = await unbodyApi.searchArticles()
|
const { data: articles = [] } = await unbodyApi.searchArticles()
|
||||||
const { data: blocks = [] } = await unbodyApi.serachBlocks()
|
const { data: blocks = [] } = await unbodyApi.serachBlocks()
|
||||||
|
const { data: topics, errors: topicErrors } = await api.getTopics()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
articles,
|
articles,
|
||||||
blocks,
|
blocks,
|
||||||
|
topics,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue