Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.
Open
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
46 changes: 23 additions & 23 deletions components/HomeContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
PoweredBy,
Configure,
InfiniteHits,
} from 'react-instantsearch-dom'
InstantSearchSSRProvider,
} from 'react-instantsearch-hooks-web'

import MeetupPreview from './MeetupPreview'
import NextMeetup from './NextMeetup'

const HomeContainer = ({nextMeetup, ...props}) => {
const HomeContainer = ({ nextMeetup, ...props }) => {
return (
<>
<Head>
Expand All @@ -34,32 +35,31 @@ const HomeContainer = ({nextMeetup, ...props}) => {
)
}

function MeetupSearch(props) {
function MeetupSearch({ serverState, ...props }) {
return (
<div className="container meetups">
<InstantSearch {...props}>
<div className="meetups__header">
<h2 className="meetups__title --withChevron">
{i18next.t('HOME_PREVIOUS_MEETUP')}
</h2>
<Configure hitsPerPage={5} />
<SearchBox
showLoadingIndicator
<InstantSearchSSRProvider {...serverState}>
<InstantSearch {...props}>
<div className="meetups__header">
<h2 className="meetups__title --withChevron">
{i18next.t('HOME_PREVIOUS_MEETUP')}
</h2>
<Configure hitsPerPage={5} />
<SearchBox
placeholder={i18next.t('SEARCH_PLACEHOLDER')}
/>
<PoweredBy />
</div>
<InfiniteHits
hitComponent={({ hit: meetup }) => (
<MeetupPreview key={meetup.objectID} meetup={meetup} />
)}
translations={{
placeholder: i18next.t('SEARCH_PLACEHOLDER'),
showMoreButtonText: i18next.t('SEARCH_LOADMORE'),
}}
/>
<PoweredBy />
</div>
<InfiniteHits
hitComponent={({ hit: meetup }) => (
<MeetupPreview key={meetup.objectID} meetup={meetup} />
)}
translations={{
loadMore: i18next.t('SEARCH_LOADMORE'),
}}
/>
</InstantSearch>
</InstantSearch>
</InstantSearchSSRProvider>
</div>
)
}
Expand Down
4 changes: 2 additions & 2 deletions components/MeetupPreview.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Highlight } from 'react-instantsearch-dom'
import { Highlight } from 'react-instantsearch-hooks-web'
import i18next from 'i18next'
import Link from 'next/link'
import TalkPreview from './TalkPreview'

function Host({ meetup }) {
return (
<span>
@ <Highlight hit={meetup} attribute="host" />
@ <Highlight hit={meetup} attribute="host" highlightedTagName="em" />
</span>
)
}
Expand Down
7 changes: 4 additions & 3 deletions components/TalkPreview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Highlight, Snippet } from 'react-instantsearch-dom'
import { Highlight, Snippet } from 'react-instantsearch-hooks-web'
import Avatar from './Avatar'

const TalkPreview = ({ talk }) => {
Expand All @@ -14,6 +14,7 @@ const TalkPreview = ({ talk }) => {
key={String(index)}
hit={talk}
attribute={`authors.${index}.name`}
highlightedTagName="em"
/>
))

Expand All @@ -23,12 +24,12 @@ const TalkPreview = ({ talk }) => {
<div className="TalkPreview__description">
<div>
<div className="TalkPreview__title">
{<Snippet hit={talk} attribute="title" />}
{<Snippet hit={talk} attribute="title" highlightedTagName="em" />}
</div>
<div className="TalkPreview__authors">{authors}</div>
</div>
<div className="TalkPreview__extract">
<Snippet hit={talk} attribute="extract" />
<Snippet hit={talk} attribute="extract" highlightedTagName="em" />
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lib/sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export const sponsors = [
},
{
name: 'Algolia',
img: '/sponsors/algolia-logo-light.png',
img: '/sponsors/algolia-logo-blue.svg',
website: 'https://www.algolia.com/',
link: { name: 'Careers', url: 'https://www.algolia.com/careers' },
},
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.1.0",
"react-instantsearch-dom": "^6.22",
"react-instantsearch-hooks-server": "^6.44.2",
"react-instantsearch-hooks-web": "^6.44.2",
"react-jsonschema-form": "^1.8.1"
},
"devDependencies": {
Expand Down
32 changes: 8 additions & 24 deletions pages/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import algoliasearch from 'algoliasearch/lite'
import { findResultsState } from 'react-instantsearch-dom/server'
import { useState } from 'react'
import { getServerState } from 'react-instantsearch-hooks-server'
import { renderToString } from 'react-dom/server'
import { RouterContext } from 'next/dist/shared/lib/router-context'

import HomeContainer from '../components/HomeContainer'
Expand All @@ -19,7 +19,6 @@ const DEFAULT_PROPS = {

export async function getStaticProps({ router, locale }) {
initI18next(locale)
const searchState = {}

function ServerSideSearch(props) {
return (
Expand All @@ -28,21 +27,16 @@ export async function getStaticProps({ router, locale }) {
</RouterContext.Provider>
)
}
const resultsState = await findResultsState(ServerSideSearch, {
...DEFAULT_PROPS,
searchState,
})
const serverState = await getServerState(
<ServerSideSearch {...DEFAULT_PROPS} />,
{ renderToString }
)

// load the next scheduled meetup
const nextMeetup = await getNextMeetup()
return {
props: {
resultsState: {
...resultsState,
metadata: [],
state: JSON.parse(JSON.stringify(resultsState.state)),
},
searchState,
serverState,
nextMeetup,
},
// Incremental Static Regeneration each minute
Expand All @@ -51,15 +45,5 @@ export async function getStaticProps({ router, locale }) {
}

export default function Index(props) {
const [searchState, setSearchState] = useState(props.searchState)
return (
<HomeContainer
{...DEFAULT_PROPS}
searchState={searchState}
onSearchStateChange={setSearchState}
createURL={() => {}}
resultsState={props.resultsState}
nextMeetup={props.nextMeetup}
/>
)
return <HomeContainer {...DEFAULT_PROPS} {...props} />
}
1 change: 1 addition & 0 deletions public/sponsors/algolia-logo-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/sponsors/algolia-logo-light.png
Binary file not shown.
Loading