Created
March 9, 2022 06:27
-
-
Save velotiotech/be77c5b0b137fa0fd52e402f8f8cada3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Footer from '../components/Footer'; | |
import Page from '../components/Page'; | |
import Story from '../components/Story'; | |
import fetchData from '../lib/api'; | |
export async function getServerSideProps() { | |
const storyIds = await fetchData('storyIds'); | |
const data = await Promise.all( | |
storyIds.slice(0, 30).map(async (id) => await fetchData(`item/${id}`)) | |
); | |
return { | |
props: { | |
data, | |
}, | |
}; | |
} | |
export default function News({ data }) { | |
return ( | |
<Page> | |
{data?.map((item, i) => ( | |
<Story key={i} {...item} /> | |
))} | |
<Footer /> | |
</Page> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment