From 4c9b3b428bad378a22cb34e55b51442fe49564bc Mon Sep 17 00:00:00 2001 From: Ike Saunders Date: Mon, 9 Dec 2024 09:52:59 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20default=20gdoc=20thumbnail?= =?UTF-8?q?s=20not=20rendering=20in=20gdocs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- baker/algolia/utils/pages.ts | 2 +- site/search/SearchPanel.tsx | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/baker/algolia/utils/pages.ts b/baker/algolia/utils/pages.ts index d6303b2fd06..e5b5983d9cd 100644 --- a/baker/algolia/utils/pages.ts +++ b/baker/algolia/utils/pages.ts @@ -162,7 +162,7 @@ function getGdocThumbnailUrl(gdoc: OwidGdocPostInterface): string { if (gdoc.content["featured-image"]) { return getThumbnailPath(gdoc.content["featured-image"]) } - return `/${DEFAULT_GDOC_FEATURED_IMAGE}` + return `/images/published/${DEFAULT_GDOC_FEATURED_IMAGE}` } function generateGdocRecords( diff --git a/site/search/SearchPanel.tsx b/site/search/SearchPanel.tsx index 26833ed4bf5..b6f8b9eddf5 100644 --- a/site/search/SearchPanel.tsx +++ b/site/search/SearchPanel.tsx @@ -11,6 +11,7 @@ import { groupBy, uniqBy, Region, + DEFAULT_GDOC_FEATURED_IMAGE, } from "@ourworldindata/utils" import { InstantSearch, @@ -65,6 +66,12 @@ import { ChartHit } from "./ChartHit.js" const siteAnalytics = new SiteAnalytics() function PagesHit({ hit }: { hit: IPageHit }) { + // a temporary fix for articles that have been indexed without the directory + const src = + hit.thumbnailUrl === `/${DEFAULT_GDOC_FEATURED_IMAGE}` + ? `/images/published/${DEFAULT_GDOC_FEATURED_IMAGE}` + : hit.thumbnailUrl + return (