diff --git a/components/context/ProductSubLandingContext.tsx b/components/context/ProductSubLandingContext.tsx index 0611a9cfd0..d701a9076f 100644 --- a/components/context/ProductSubLandingContext.tsx +++ b/components/context/ProductSubLandingContext.tsx @@ -6,7 +6,7 @@ export type FeaturedTrack = { title: string description: string guides?: Array<{ href: string; page: { type: string }; title: string; intro: string }> -} +} | null export type ArticleGuide = { href: string @@ -45,12 +45,12 @@ export const getProductSubLandingContextFromRequest = (req: any): ProductSubLand return { ...pick(page, ['intro', 'allTopics']), title: req.context.productMap[req.context.currentProduct].name, - featuredTrack: { + featuredTrack: page.featuredTrack ? { ...pick(page.featuredTrack, ['title', 'description', 'trackName', 'guides']), guides: (page.featuredTrack?.guides || []).map((guide: any) => { return pick(guide, ['title', 'intro', 'href', 'page.type']) - }), - }, + }) + } : null, learningTracks: (page.learningTracks || []).map((track: any) => ({ ...pick(track, ['title', 'description', 'trackName', 'guides']), guides: (track.guides || []).map((guide: any) => { @@ -58,7 +58,7 @@ export const getProductSubLandingContextFromRequest = (req: any): ProductSubLand }), })), includeGuides: (page.includeGuides || []).map((guide: any) => { - return pick(guide, ['href', 'title', 'intro', 'type', 'topics']) + return pick(guide, ['href', 'title', 'intro', 'page.type', 'topics']) }), } } diff --git a/components/sublanding/LearningTrack.tsx b/components/sublanding/LearningTrack.tsx index 5341ca0c86..2e55420b1f 100644 --- a/components/sublanding/LearningTrack.tsx +++ b/components/sublanding/LearningTrack.tsx @@ -9,9 +9,9 @@ type Props = { const MAX_VISIBLE_GUIDES = 4 export const LearningTrack = ({ track }: Props) => { - const [visibleGuides, setVisibleGuides] = useState(track.guides?.slice(0, 4)) + const [visibleGuides, setVisibleGuides] = useState(track?.guides?.slice(0, 4)) const showAll = () => { - setVisibleGuides(track.guides) + setVisibleGuides(track?.guides) } const { t } = useTranslation('product_sublanding') @@ -21,16 +21,16 @@ export const LearningTrack = ({ track }: Props) => {
- {track.description} + {track?.description}