Skip to content

Commit

Permalink
🎉 add baking support for the gdocs homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Feb 15, 2024
1 parent 0297010 commit 51d1962
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions baker/siteRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import {
KEY_INSIGHTS_CLASS_NAME,
} from "../site/blocks/KeyInsights.js"
import { formatUrls, KEY_INSIGHTS_H2_CLASSNAME } from "../site/formatting.js"
import * as db from "../db/db.js"

import { GrapherProgrammaticInterface } from "@ourworldindata/grapher"
import { ExplorerProgram } from "../explorer/ExplorerProgram.js"
Expand Down Expand Up @@ -246,7 +247,23 @@ export const renderPost = async (
)
}

// This function is temporarily forked until we have fully transitioned to a gdocs homepage,
// whereupon we'll strip out the old front page code.
export const renderFrontPage = async () => {
// Annoying, MySQL+TypeORM doesn't support JSONB, so I'm using raw SQL to confirm if there's a published homepage
const gdocHomepageResult = await db.knexRawFirst<{ id: string }>(
`SELECT id FROM posts_gdocs WHERE content->>"$.type" = "${OwidGdocType.Homepage}" AND published = TRUE`,
db.knexInstance()
)

if (gdocHomepageResult) {
const gdocHomepage = await GdocFactory.load(gdocHomepageResult.id, {})
if (gdocHomepage) {
await gdocHomepage.loadState({})
return renderGdoc(gdocHomepage)
}
}

const posts = await getBlogIndex()

const NUM_FEATURED_POSTS = 6
Expand Down

0 comments on commit 51d1962

Please sign in to comment.