diff --git a/packages/@ourworldindata/types/src/gdocTypes/ArchieMlComponents.ts b/packages/@ourworldindata/types/src/gdocTypes/ArchieMlComponents.ts index 06c200041d..3d1130ea3e 100644 --- a/packages/@ourworldindata/types/src/gdocTypes/ArchieMlComponents.ts +++ b/packages/@ourworldindata/types/src/gdocTypes/ArchieMlComponents.ts @@ -245,6 +245,10 @@ export type EnrichedBlockImage = { originalWidth?: number size: BlockImageSize hasOutline: boolean + // Not a real ArchieML prop - we set this to true for Data Insights, as a way to migrate + // first generation data insights to only use their small image + // See https://github.com/owid/owid-grapher/issues/4416 + preferSmallFilename?: boolean } & EnrichedBlockWithParseErrors export type RawBlockVideo = { diff --git a/site/DataInsightsIndexPageContent.tsx b/site/DataInsightsIndexPageContent.tsx index 42224b6e43..feed9ebdd0 100644 --- a/site/DataInsightsIndexPageContent.tsx +++ b/site/DataInsightsIndexPageContent.tsx @@ -117,10 +117,10 @@ export const DataInsightsIndexPageContent = ( }} >
-

+

Daily Data Insights

-

+

Bite-sized insights on how the world is changing, published every weekday.

diff --git a/site/gdocs/OwidGdocPage.tsx b/site/gdocs/OwidGdocPage.tsx index ed80dd3699..8ee697f6e5 100644 --- a/site/gdocs/OwidGdocPage.tsx +++ b/site/gdocs/OwidGdocPage.tsx @@ -21,6 +21,7 @@ import { import { DATA_INSIGHT_ATOM_FEED_PROPS } from "../SiteConstants.js" import { Html } from "../Html.js" import { CLOUDFLARE_IMAGES_URL } from "../../settings/clientSettings.js" +import { addPreferSmallFilenameToDataInsightImages } from "../gdocs/utils.js" declare global { interface Window { @@ -111,6 +112,10 @@ export default function OwidGdocPage({ } } + if (gdoc.content.type === OwidGdocType.DataInsight) { + addPreferSmallFilenameToDataInsightImages(gdoc.content) + } + return ( {block.caption ? (
( diff --git a/site/gdocs/pages/DataInsight.scss b/site/gdocs/pages/DataInsight.scss index dbe779ea18..df28885623 100644 --- a/site/gdocs/pages/DataInsight.scss +++ b/site/gdocs/pages/DataInsight.scss @@ -30,7 +30,7 @@ } @include sm-only { - margin: 16px 0 20px 0; + display: none; } } @@ -41,11 +41,12 @@ .data-insight-body { background-color: #fff; padding: 24px; - margin-bottom: 48px; + margin-bottom: 30px; h1 { margin-top: 0; - margin-bottom: 12px; + margin-bottom: 8px; + font-size: 1.875rem; } .article-block__image { @@ -53,23 +54,22 @@ margin-top: 24px; } + .article-block__text { + font-size: 1rem; + } + @include md-down { padding: 16px; margin-bottom: 24px; h1 { - font-size: 1.625rem; - margin-bottom: 12px; + font-size: 1.375rem; } .article-block__image { margin-top: 16px; margin-bottom: 24px; } - - .article-block__text { - font-size: 1rem; - } } } diff --git a/site/gdocs/pages/DataInsight.tsx b/site/gdocs/pages/DataInsight.tsx index 5ea013fe43..9ff8b7920c 100644 --- a/site/gdocs/pages/DataInsight.tsx +++ b/site/gdocs/pages/DataInsight.tsx @@ -54,7 +54,7 @@ const RelatedTopicsList = ({ if (!tags?.length) return null return (
-

Related topic pages:

+

Related topic pages:

    {tags.map((tag) => (
  • @@ -109,7 +109,7 @@ export const DataInsightBody = (
    -
    +
    Daily Data Insights {props.content.title} diff --git a/site/gdocs/utils.ts b/site/gdocs/utils.ts index 18675be683..ad476c0992 100644 --- a/site/gdocs/utils.ts +++ b/site/gdocs/utils.ts @@ -11,8 +11,13 @@ import { CategoryWithEntries, EntryMeta, SubNavId, + OwidGdocDataInsightContent, } from "@ourworldindata/types" -import { formatAuthors, Url } from "@ourworldindata/utils" +import { + formatAuthors, + traverseEnrichedBlock, + Url, +} from "@ourworldindata/utils" import { AttachmentsContext } from "./AttachmentsContext.js" import { SiteNavigationStatic, SubnavItem, subnavs } from "../SiteConstants.js" @@ -201,3 +206,19 @@ export const getTopSubnavigationParentItem = ( ): SubnavItem | undefined => { return subnavs[subnavId]?.[0] } + +// Always use the smallFilename for old data insights, where two filenames were always provided +// Doing this in code was simpler than migrating all the DI gdocs themselves +// See https://github.com/owid/owid-grapher/issues/4416 +export function addPreferSmallFilenameToDataInsightImages( + content: OwidGdocDataInsightContent +): OwidGdocDataInsightContent { + content.body.forEach((node) => + traverseEnrichedBlock(node, (block) => { + if (block.type === "image") { + block.preferSmallFilename = true + } + }) + ) + return content +}