2017-01-22 13:27:06 +01:00
|
|
|
|
import App from '../components/App'
|
2019-09-04 18:46:39 +02:00
|
|
|
|
import InfoBox from '../components/InfoBox'
|
2017-01-22 13:27:06 +01:00
|
|
|
|
import Header from '../components/Header'
|
|
|
|
|
import Submit from '../components/Submit'
|
2020-06-05 17:41:42 +02:00
|
|
|
|
import PostList, {
|
|
|
|
|
ALL_POSTS_QUERY,
|
|
|
|
|
allPostsQueryVars,
|
|
|
|
|
} from '../components/PostList'
|
|
|
|
|
import { initializeApollo } from '../lib/apolloClient'
|
2017-01-22 13:27:06 +01:00
|
|
|
|
|
2020-02-13 06:26:22 +01:00
|
|
|
|
const IndexPage = () => (
|
2017-01-22 13:27:06 +01:00
|
|
|
|
<App>
|
2017-12-18 11:25:06 +01:00
|
|
|
|
<Header />
|
2020-06-05 17:41:42 +02:00
|
|
|
|
<InfoBox>ℹ️ This page shows how to use SSG with Apollo.</InfoBox>
|
2017-01-22 13:27:06 +01:00
|
|
|
|
<Submit />
|
|
|
|
|
<PostList />
|
|
|
|
|
</App>
|
2018-05-07 15:02:56 +02:00
|
|
|
|
)
|
2019-08-25 04:19:26 +02:00
|
|
|
|
|
2020-06-05 17:41:42 +02:00
|
|
|
|
export async function getStaticProps() {
|
|
|
|
|
const apolloClient = initializeApollo()
|
|
|
|
|
|
|
|
|
|
await apolloClient.query({
|
|
|
|
|
query: ALL_POSTS_QUERY,
|
|
|
|
|
variables: allPostsQueryVars,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
props: {
|
|
|
|
|
initialApolloState: apolloClient.cache.extract(),
|
|
|
|
|
},
|
|
|
|
|
unstable_revalidate: 1,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default IndexPage
|