fix: filter out docs that don't match podcast episodes

This commit is contained in:
Hossein Mehrabi 2023-08-18 14:23:46 +03:30
parent 3363b15587
commit 584d4535ca
No known key found for this signature in database
GPG Key ID: 45C04964191AFAA1
2 changed files with 9 additions and 8 deletions

View File

@ -22,7 +22,7 @@ export const PodcastEpisodeDataType: UnbodyDataTypeConfig<
isMatch: (helpers, data, original) => isMatch: (helpers, data, original) =>
original original
? original.pathString.includes('/Podcasts/') && ? original.pathString.includes('/Podcasts/') &&
original.slug.startsWith('ep') /^ep\d+-\d{8}-.*/.test(original.slug)
: false, : false,
transform: async (helpers, data, original, root, context) => { transform: async (helpers, data, original, root, context) => {
@ -97,7 +97,6 @@ export const PodcastEpisodeDataType: UnbodyDataTypeConfig<
coverImage, coverImage,
show, show,
showId: show?.id, showId: show?.id,
featured: data.featured,
highlighted: data.highlighted, highlighted: data.highlighted,
type: LPE.PostTypes.Podcast, type: LPE.PostTypes.Podcast,
} }

View File

@ -519,12 +519,14 @@ export class UnbodyService {
shows = [...data] shows = [...data]
} }
return unbodyDataTypes.transformMany<LPE.Podcast.Document>( return unbodyDataTypes
podcastEpisodeDocument, .transformMany<LPE.Podcast.Document>(
docs, podcastEpisodeDocument,
undefined, docs,
{ shows, parseContent }, undefined,
) { shows, parseContent },
)
.then((res) => res.filter((obj) => obj && obj.type === 'podcast'))
}, []) }, [])
getPodcastEpisode = ({ getPodcastEpisode = ({