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)