Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix default gdoc thumbnails not rendering in gdocs #4270

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion baker/algolia/utils/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 8 additions & 1 deletion site/search/SearchPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
groupBy,
uniqBy,
Region,
DEFAULT_GDOC_FEATURED_IMAGE,
} from "@ourworldindata/utils"
import {
InstantSearch,
Expand Down Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be removed as part of #4214

const src =
hit.thumbnailUrl === `/${DEFAULT_GDOC_FEATURED_IMAGE}`
? `/images/published/${DEFAULT_GDOC_FEATURED_IMAGE}`
: hit.thumbnailUrl

return (
<a
href={`${BAKED_BASE_URL}/${hit.slug}`}
Expand All @@ -76,7 +83,7 @@ function PagesHit({ hit }: { hit: IPageHit }) {
{hit.thumbnailUrl && (
<div className="search-results__page-hit-img-container">
<img
src={hit.thumbnailUrl}
src={src}
role="presentation"
className="search-results__page-hit-img"
/>
Expand Down
Loading