commit
8657a4e95f
2
.env
2
.env
|
@ -6,4 +6,4 @@ DISCORD_LOGS_WEBHOOK_URL=
|
|||
NEXT_PUBLIC_SITE_URL=
|
||||
FATHOM_SITE_ID=
|
||||
NEXT_PUBLIC_ODOO_BASE_URL=https://odoo.logos.co
|
||||
NEXT_PUBLIC_ODOO_MAILING_LIST_ID=2
|
||||
NEXT_PUBLIC_ODOO_MAILING_LIST_ID=2
|
||||
|
|
|
@ -43,7 +43,10 @@ const PodcastShowPage = ({
|
|||
export const getStaticProps = async ({ params }: GetStaticPropsContext) => {
|
||||
// TODO : error handling
|
||||
const { data: podcastShows, errors: podcastShowsErrors } =
|
||||
await unbodyApi.getPodcastShows({ populateEpisodes: false })
|
||||
await unbodyApi.getPodcastShows({
|
||||
populateEpisodes: true,
|
||||
episodesLimit: 6,
|
||||
})
|
||||
|
||||
// TODO : error handling
|
||||
const { data: highlightedEpisodes, errors: highlightedEpisodesErrors } =
|
||||
|
@ -62,11 +65,20 @@ export const getStaticProps = async ({ params }: GetStaticPropsContext) => {
|
|||
}
|
||||
}
|
||||
|
||||
const latestEps = podcastShows
|
||||
.flatMap((show) => show.episodes)
|
||||
.sort((a, b) => {
|
||||
const aDate = new Date(a!.publishedAt)
|
||||
const bDate = new Date(b!.publishedAt)
|
||||
return aDate > bDate ? -1 : 1
|
||||
})
|
||||
.filter((p) => p?.highlighted !== true)
|
||||
|
||||
return {
|
||||
props: {
|
||||
shows: podcastShows,
|
||||
highlightedEpisodes,
|
||||
latestEpisodes: latestEpisodes.map((ep) => ({ ...ep, show: null })),
|
||||
latestEpisodes: latestEps,
|
||||
// errors,
|
||||
},
|
||||
revalidate: 10,
|
||||
|
|
|
@ -73,7 +73,7 @@ const getRecordDate = (record: PageRecord) =>
|
|||
? new Date(record.publishedAt)
|
||||
: new Date(record.modifiedAt!)
|
||||
|
||||
const sortPosts = (a: LPE.Post.Document, b: LPE.Post.Document) =>
|
||||
export const sortPosts = (a: LPE.Post.Document, b: LPE.Post.Document) =>
|
||||
getRecordDate(a) > getRecordDate(b) ? -1 : 1
|
||||
|
||||
type PageRecord = LPE.Post.Document | LPE.StaticPage.Document
|
||||
|
@ -228,7 +228,7 @@ export class UnbodyService {
|
|||
else newData.draftStaticPages.push(staticPage)
|
||||
}
|
||||
|
||||
newData.posts = [...newData.articles, ...newData.episodes]
|
||||
newData.posts = [...newData.articles, ...newData.episodes].sort(sortPosts)
|
||||
newData.allRecords = [...articles, ...episodes, ...staticPages]
|
||||
|
||||
const oldData = { ...this.data }
|
||||
|
|
Loading…
Reference in New Issue