@arakida - 3y
pages/index.tsx
1type Props = {2 items: Item[]3}45export const getStaticProps: GetStaticProps<Props> = async () => {6 const API: GraphQLAPIClass = withSSRContext().API78 const queryVariables: ListItemQueryVariables = {9 sortDirection: ModelSortDirection.DESC,10 limit: 20,11 }1213 const res = (await API.graphql({14 query: listItem,15 variables: queryVariables,16 })) as GraphQLResult<ListItemQuery>1718 const items = res.data?.listItem?.items ?? []1920 return {21 props: {22 items: items,23 },24 revalidate: 5,25 }26}2728const Home: NextPage<Props> = ({ items }) => {29 return (30 <>31 {items.map((v, i) => (32 <div key={i}>33 <h1>{v.title}</h1>34 <h2>{v.owner}</h2>35 <p>{v.content}</p>36 </div>37 ))}38 </>39 )40}4142export default Home