diff --git a/baker/siteRenderers.tsx b/baker/siteRenderers.tsx index a37b8092a64..05da0c012c0 100644 --- a/baker/siteRenderers.tsx +++ b/baker/siteRenderers.tsx @@ -65,9 +65,6 @@ import { getPostBySlug, isPostCitable, getBlockContent, - getPosts, - mapGdocsToWordpressPosts, - getFullPost, } from "../db/wpdb.js" import { queryMysql, knexTable } from "../db/db.js" import { getPageOverrides, isPageOverridesCitable } from "./pageOverrides.js" @@ -226,21 +223,7 @@ export const renderPost = async ( } export const renderFrontPage = async () => { - const wpPosts = await Promise.all( - (await getPosts()).map((post) => getFullPost(post, true)) - ) - const gdocPosts = await Gdoc.getPublishedGdocs().then( - mapGdocsToWordpressPosts - ) - const gdocSlugs = new Set(gdocPosts.map(({ slug }) => slug)) - const posts = [...gdocPosts] - // Only adding each wpPost if there isn't already a gdoc with the same slug, - // to make sure we use the most up-to-date metadata - for (const wpPost of wpPosts) { - if (!gdocSlugs.has(wpPost.slug)) { - posts.push(wpPost) - } - } + const posts = await getBlogIndex() const NUM_FEATURED_POSTS = 6 @@ -290,6 +273,10 @@ export const renderFrontPage = async () => { if (post) { return post } + console.log( + "Featured work error: could not find listed post with slug: ", + manuallySetPost.slug + ) } return filteredPosts[missingPosts++] }) diff --git a/db/wpdb.ts b/db/wpdb.ts index cd721aea00b..8e6ad4957a9 100644 --- a/db/wpdb.ts +++ b/db/wpdb.ts @@ -751,24 +751,26 @@ export const getFullPost = async ( }) export const getBlogIndex = memoize(async (): Promise => { - // TODO: do not get post content in the first place - const wordpressPosts = await getPosts( - [WP_PostType.Post], - selectHomepagePosts + await db.getConnection() // side effect: ensure connection is established + const gdocPosts = await Gdoc.getListedGdocs() + const wpPosts = await Promise.all( + await getPosts([WP_PostType.Post], selectHomepagePosts).then((posts) => + posts.map((post) => getFullPost(post, true)) + ) ) - const wordpressPostsCards = await Promise.all( - wordpressPosts.map((post) => getFullPost(post, true)) - ) + const gdocSlugs = new Set(gdocPosts.map(({ slug }) => slug)) + const posts = [...mapGdocsToWordpressPosts(gdocPosts)] - await db.getConnection() // side effect: ensure connection is established - const listedGdocs = await Gdoc.getListedGdocs() + // Only adding each wpPost if there isn't already a gdoc with the same slug, + // to make sure we use the most up-to-date metadata + for (const wpPost of wpPosts) { + if (!gdocSlugs.has(wpPost.slug)) { + posts.push(wpPost) + } + } - return orderBy( - [...wordpressPostsCards, ...mapGdocsToWordpressPosts(listedGdocs)], - (post) => post.date.getTime(), - ["desc"] - ) + return orderBy(posts, (post) => post.date.getTime(), ["desc"]) }) export const mapGdocsToWordpressPosts = ( diff --git a/site/SiteMobileCategory.scss b/site/SiteMobileCategory.scss index f91b69cc09d..cbf7002d086 100644 --- a/site/SiteMobileCategory.scss +++ b/site/SiteMobileCategory.scss @@ -7,6 +7,7 @@ width: 100%; align-items: center; justify-content: space-between; + text-align: left; padding: 8px 16px; color: $blue-60; line-height: 21px; diff --git a/site/SiteMobileMenu.scss b/site/SiteMobileMenu.scss index 6cdb368e42d..441946406b2 100644 --- a/site/SiteMobileMenu.scss +++ b/site/SiteMobileMenu.scss @@ -43,6 +43,7 @@ .SiteNavigationToggle__caret { font-size: 12px; + margin-right: 8px; } .SiteNavigationToggle__dropdown { ul { diff --git a/site/SiteNavigationTopics.scss b/site/SiteNavigationTopics.scss index f9585e5bf72..03e5480f31f 100644 --- a/site/SiteNavigationTopics.scss +++ b/site/SiteNavigationTopics.scss @@ -40,6 +40,7 @@ background-color: transparent; cursor: pointer; border: none; + white-space: break-spaces; // pseudo elements for ensuring continuity of hover between // bordering items while still having a visual gap between an // active element and its adjacent siblings @@ -125,6 +126,7 @@ .SiteNavigationTopic { list-style-type: none; break-inside: avoid-column; + white-space: break-spaces; @include body-3-medium; > a { display: block; diff --git a/site/gdocs/ArticleBlock.tsx b/site/gdocs/ArticleBlock.tsx index 9f9f282cf85..936957837f2 100644 --- a/site/gdocs/ArticleBlock.tsx +++ b/site/gdocs/ArticleBlock.tsx @@ -78,11 +78,11 @@ const layouts: { [key in Container]: Layouts} = { ["sdg-grid"]: "grid col-start-2 span-cols-12 col-lg-start-3 span-lg-cols-10 span-sm-cols-12 col-sm-start-2", ["sdg-toc"]: "grid grid-cols-8 col-start-4 span-cols-8 grid-md-cols-10 col-md-start-3 span-md-cols-10 grid-sm-cols-12 span-sm-cols-12 col-sm-start-2", ["side-by-side"]: "grid span-cols-12 col-start-2", - ["sticky-left-left-column"]: "grid grid-cols-7 span-cols-7 span-md-cols-12 grid-md-cols-12", - ["sticky-left-right-column"]: "grid grid-cols-5 span-cols-5 span-md-cols-12 grid-md-cols-12", + ["sticky-left-left-column"]: "grid grid-cols-7 span-cols-7 span-md-cols-10 grid-md-cols-10", + ["sticky-left-right-column"]: "grid grid-cols-5 span-cols-5 span-md-cols-10 grid-md-cols-10", ["sticky-left"]: "grid span-cols-12 col-start-2", - ["sticky-right-left-column"]: "grid span-cols-5 grid grid-cols-5 span-md-cols-12 grid-md-cols-12", - ["sticky-right-right-column"]: "span-cols-7 span-md-cols-12", + ["sticky-right-left-column"]: "grid span-cols-5 grid grid-cols-5 span-md-cols-10 grid-md-cols-10 col-md-start-2 span-sm-cols-12 grid-sm-cols-12 col-sm-start-1", + ["sticky-right-right-column"]: "span-cols-7 grid-cols-7 span-md-cols-10 grid-md-cols-10 col-md-start-2 span-sm-cols-12 grid-sm-cols-12 col-sm-start-1", ["sticky-right"]: "grid span-cols-12 col-start-2", ["text"]: "col-start-5 span-cols-6 col-md-start-3 span-md-cols-10 span-sm-cols-12 col-sm-start-2", ["topic-page-intro"]: "grid col-start-2 span-cols-12", diff --git a/site/gdocs/OwidGdocHeader.tsx b/site/gdocs/OwidGdocHeader.tsx index 2caaaaa6bf7..a309996620c 100644 --- a/site/gdocs/OwidGdocHeader.tsx +++ b/site/gdocs/OwidGdocHeader.tsx @@ -47,7 +47,7 @@ function OwidArticleHeader({ ) : null} {!!breadcrumbs?.length && ( -
+
-
+
{content.supertitle ? (

{content.supertitle} @@ -70,11 +72,11 @@ function OwidArticleHeader({

{content.subtitle ? ( -

+

{content.subtitle}

) : null} -
+
{"By: "} diff --git a/site/gdocs/centered-article.scss b/site/gdocs/centered-article.scss index a4e6092549e..f8bc14930b1 100644 --- a/site/gdocs/centered-article.scss +++ b/site/gdocs/centered-article.scss @@ -30,7 +30,7 @@ $banner-height: 200px; left: 0; right: 0; height: $banner-height; - background: $blue-10; + background: $amber; z-index: -1; } @@ -58,6 +58,11 @@ $banner-height: 200px; margin: 80px 0 24px; min-height: calc($banner-height - 80px); padding-top: 48px; + + @include md-down { + margin-top: 48px; + padding-top: 24px; + } } .article-block__text { @@ -110,6 +115,10 @@ h3.article-block__heading { img { width: 100%; + + &.lightbox-image { + cursor: zoom-in; + } } .download-png-link { @@ -133,6 +142,10 @@ h3.article-block__heading { text-align: center; } +.article-block__chart + .article-block__heading { + margin-top: 0; +} + .article-block__heading + .article-block__heading { margin-top: 0; } @@ -183,11 +196,14 @@ h3.article-block__heading.has-supertitle { // take up exactly: (number of lines - 1) * line-height // in height, effectively, such that the header is always the same height // unless the breadcrumbs are longer than a single line. - $header-breadcrumb-margin-top: 40px; - margin-top: $header-breadcrumb-margin-top; - margin-bottom: calc(-1.6em - $header-breadcrumb-margin-top); - // lh is a relatively recent CSS unit, so we use ems as a fallback in the rule above - margin-bottom: calc(-1lh - $header-breadcrumb-margin-top); + --header-breadcrumb-margin-top: 40px; + + @include md-down { + --header-breadcrumb-margin-top: 16px; + } + + margin-top: var(--header-breadcrumb-margin-top); + margin-bottom: calc(-1.6em - var(--header-breadcrumb-margin-top)); font-size: 1rem; a { @@ -219,6 +235,11 @@ h3.article-block__heading.has-supertitle { margin-top: 0; margin-bottom: 24px; color: $blue-90; + + @include md-down { + @include h2-bold; + margin-top: 0; + } } } @@ -226,6 +247,10 @@ h3.article-block__heading.has-supertitle { @include subtitle-1; margin-top: 0; color: $blue-50; + + @include md-down { + @include body-1-regular; + } } .centered-article-header__meta-container { @@ -258,6 +283,15 @@ h3.article-block__heading.has-supertitle { border-right: 1px solid $blue-10; } } + + @include sm-only { + padding: 16px 0; + > div:first-child { + border-bottom: 1px solid $blue-10; + padding-bottom: 16px; + margin-bottom: 16px; + } + } } .footnote-container, @@ -451,6 +485,13 @@ h3.article-block__heading.has-supertitle { .article-block__explorer { margin-top: 0; } + + .article-block__chart, + .article-block__image { + &:last-child { + margin-bottom: 0; + } + } } .article-block__chart, @@ -643,6 +684,10 @@ h3.article-block__heading.has-supertitle { .article-block__sticky-left, .article-block__side-by-side { margin: 48px 0; + + @include md-down { + margin: 0; + } } .article-block__prominent-link {