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 ec89e8c
Show file tree
Hide file tree
Showing 2 changed files with 10 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
}
15 changes: 10 additions & 5 deletions site/multiDim/MultiDimDataPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import urljoin from "url-join"
import { Head } from "../Head.js"
import { IFrameDetector } from "../IframeDetector.js"
import { SiteHeader } from "../SiteHeader.js"
Expand All @@ -18,7 +19,6 @@ export function MultiDimDataPage({
primaryTopic,
relatedResearchCandidates,
imageMetadata,
initialQueryStr,
isPreviewing,
}: MultiDimDataPageProps) {
const canonicalUrl = `${baseGrapherUrl}/${slug}`
Expand All @@ -31,19 +31,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")
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 ec89e8c

Please sign in to comment.