Skip to content

Commit

Permalink
Add preview image to multidimensional data pages
Browse files Browse the repository at this point in the history
We can't use a dynamic thumbnail, because the meta tags are generated
during baking. We could switch to dynamic thumbnails if/when we move the
Grapher pages to dynamic rendering, i.e Cloudflare functions.
  • Loading branch information
rakyi committed Jan 22, 2025
1 parent 506271a commit 9287b52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,5 @@ export interface MultiDimDataPageProps {
primaryTopic?: PrimaryTopic
relatedResearchCandidates: DataPageRelatedResearch[]
imageMetadata: Record<string, ImageMetadata>
initialQueryStr?: string
isPreviewing?: boolean
}
14 changes: 9 additions & 5 deletions site/multiDim/MultiDimDataPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function MultiDimDataPage({
primaryTopic,
relatedResearchCandidates,
imageMetadata,
initialQueryStr,
isPreviewing,
}: MultiDimDataPageProps) {
const canonicalUrl = `${baseGrapherUrl}/${slug}`
Expand All @@ -31,19 +30,24 @@ export function MultiDimDataPage({
relatedResearchCandidates,
imageMetadata,
tagToSlugMap,
initialQueryStr,
}
// Due to thumbnails not taking into account URL parameters, they are often inaccurate on
// social media. We decided to remove them and use a single thumbnail for all charts.
// See https://github.com/owid/owid-grapher/issues/1086
const imageUrl: string = urljoin(baseUrl, "default-grapher-thumbnail.png")

Check failure on line 37 in site/multiDim/MultiDimDataPage.tsx

View workflow job for this annotation

GitHub Actions / testcheck

'urljoin' refers to a UMD global, but the current file is a module. Consider adding an import instead.

Check failure on line 37 in site/multiDim/MultiDimDataPage.tsx

View workflow job for this annotation

GitHub Actions / bundlewatch

'urljoin' refers to a UMD global, but the current file is a module. Consider adding an import instead.

Check failure on line 37 in site/multiDim/MultiDimDataPage.tsx

View workflow job for this annotation

GitHub Actions / testdbcheck

'urljoin' refers to a UMD global, but the current file is a module. Consider adding an import instead.

Check failure on line 37 in site/multiDim/MultiDimDataPage.tsx

View workflow job for this annotation

GitHub Actions / bundlewatch

'urljoin' refers to a UMD global, but the current file is a module. Consider adding an import instead.

Check failure on line 37 in site/multiDim/MultiDimDataPage.tsx

View workflow job for this annotation

GitHub Actions / testcheck

'urljoin' refers to a UMD global, but the current file is a module. Consider adding an import instead.

Check failure on line 37 in site/multiDim/MultiDimDataPage.tsx

View workflow job for this annotation

GitHub Actions / testdbcheck

'urljoin' refers to a UMD global, but the current file is a module. Consider adding an import instead.
const imageWidth = "1200"
const imageHeight = "628"
return (
<Html>
<Head
canonicalUrl={canonicalUrl}
// pageTitle={pageTitle}
// pageDesc={pageDesc}
// imageUrl={imageUrl}
imageUrl={imageUrl}
baseUrl={baseUrl}
>
{/* <meta property="og:image:width" content={imageWidth} />
<meta property="og:image:height" content={imageHeight} /> */}
<meta property="og:image:width" content={imageWidth} />
<meta property="og:image:height" content={imageHeight} />
<IFrameDetector />
<noscript>
<style>{`
Expand Down

0 comments on commit 9287b52

Please sign in to comment.