Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created March 9, 2022 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/be77c5b0b137fa0fd52e402f8f8cada3 to your computer and use it in GitHub Desktop.
Save velotiotech/be77c5b0b137fa0fd52e402f8f8cada3 to your computer and use it in GitHub Desktop.
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