[site/home]: add featured pages to props

This commit is contained in:
khalilcodes 2022-04-27 18:48:06 +03:00
parent 74660d2ac1
commit 6fb734eccd
1 changed files with 26 additions and 4 deletions

View File

@ -4,16 +4,38 @@ import Features from 'components/Home/Features'
import Why from 'components/Home/Why'
import GetInvolved from 'components/Home/Get-Involved'
import { NextSeo } from 'next-seo'
import { allOtherPages } from 'contentlayer/generated'
export default function Home(props) {
export default function Home({ featuredPages }) {
return (
<>
<NextSeo title='Home' />
<NextSeo title="Home" />
<Hero />
<Latest />
<Latest posts={featuredPages} />
<Features />
<Why />
<GetInvolved />
</>
)
);
}
export async function getStaticProps () {
const featuredPages = allOtherPages
.filter((page) => page.featured !== undefined && page.featured)
.sort((a, b) => new Date(b.date) - new Date(a.date))
.map((page) => {
return {
title: page.title ?? null,
description: page.description ?? null,
image: page.image ?? null,
youtube: page.youtube ?? null,
link: `/${page._raw.flattenedPath}`,
}
})
return {
props: {
featuredPages
}
}
}