From 66aea84d4df335058c00d94a4d0742373ed51d11 Mon Sep 17 00:00:00 2001 From: Daniel O'Connell Date: Thu, 11 Jul 2024 13:31:53 +0200 Subject: [PATCH] Filter out non live articles from the default related questions --- app/server-utils/stampy.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/server-utils/stampy.ts b/app/server-utils/stampy.ts index 545a34e7..6fb80eb4 100644 --- a/app/server-utils/stampy.ts +++ b/app/server-utils/stampy.ts @@ -381,7 +381,12 @@ export const loadBanners = withCache('loadBanners', async (): Promise { const rows = (await getCodaRows(ON_SITE_TABLE)) as AnswersRow[] - return rows.map(convertToQuestion) + const cleaned = rows.map(convertToQuestion) + const questionIds = cleaned.map((q) => q.pageid) + return cleaned.map((q) => ({ + ...q, + relatedQuestions: q.relatedQuestions.filter(({pageid}) => questionIds.includes(pageid)), + })) }) export const loadAllQuestions = withCache('allQuestions', async () => {