From 6afe4ee25de8d621d0db4bcd5a36c398032c106a Mon Sep 17 00:00:00 2001 From: Lars Yencken Date: Fri, 8 Nov 2024 10:53:55 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20Fix=20FAQ=20images=20on=20data?= =?UTF-8?q?=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #3862 (Lars experimenting with Copilot Workspace) --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/owid/owid-grapher/issues/3862?shareId=XXXX-XXXX-XXXX-XXXX). --- baker/DatapageHelpers.ts | 6 ++++++ baker/GrapherBaker.tsx | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/baker/DatapageHelpers.ts b/baker/DatapageHelpers.ts index 8d1aef9e316..e3eb003a6f8 100644 --- a/baker/DatapageHelpers.ts +++ b/baker/DatapageHelpers.ts @@ -10,6 +10,8 @@ import { getNextUpdateFromVariable, omitUndefinedValues, partition, + traverseEnrichedBlocks, + extractFilenamesFromBlock, } from "@ourworldindata/utils" import { getGdocBaseObjectById, @@ -221,3 +223,7 @@ export const getPrimaryTopic = async ( } return undefined } + +export const extractFilenamesFromFaqEntries = (faqEntries: FaqEntryData) => { + return traverseEnrichedBlocks(faqEntries.faqs, extractFilenamesFromBlock) +} diff --git a/baker/GrapherBaker.tsx b/baker/GrapherBaker.tsx index baabc0cb882..a19419f99bb 100644 --- a/baker/GrapherBaker.tsx +++ b/baker/GrapherBaker.tsx @@ -11,6 +11,8 @@ import { keyBy, compact, mergeGrapherConfigs, + traverseEnrichedBlocks, + extractFilenamesFromBlock, } from "@ourworldindata/utils" import fs from "fs-extra" import * as lodash from "lodash" @@ -210,9 +212,11 @@ export async function renderDataPageV2( .map((r) => r.imageUrl) .filter((f): f is string => !!f) + const faqFilenames = traverseEnrichedBlocks(faqEntries.faqs, extractFilenamesFromBlock) + const imageMetadata = lodash.pick( imageMetadataDictionary, - uniq(relatedResearchFilenames) + uniq([...relatedResearchFilenames, ...faqFilenames]) ) const tagToSlugMap = await getTagToSlugMap(knex)