Skip to content

Commit

Permalink
✨ add narrative-chart and figma-url to DI frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Jan 27, 2025
1 parent 6063099 commit 439c38d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
17 changes: 16 additions & 1 deletion adminSiteClient/GdocsSettingsForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ export const GdocInsightSettings = ({
<form className="GdocsSettingsForm">
<GdocCommonErrors
errors={errors}
errorsToFilter={["approved-by", "grapher-url"]}
errorsToFilter={[
"approved-by",
"grapher-url",
"narrative-chart",
"figma-url",
]}
/>
<GdocCommonSettings
gdoc={gdoc}
Expand All @@ -194,11 +199,21 @@ export const GdocInsightSettings = ({
gdoc={gdoc}
errors={errors}
/>
<GdocsSettingsContentField
property="narrative-chart"
gdoc={gdoc}
errors={errors}
/>
<GdocsSettingsContentField
property="grapher-url"
gdoc={gdoc}
errors={errors}
/>
<GdocsSettingsContentField
property="figma-url"
gdoc={gdoc}
errors={errors}
/>
</div>
</form>
)
Expand Down
2 changes: 2 additions & 0 deletions adminSiteClient/gdocsDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export const checkIsLightningUpdate = (
> = {
["grapher-url"]: true,
["approved-by"]: true,
["narrative-chart"]: true,
["figma-url"]: true,
title: false, // requires rebaking the feed
authors: false, // requires rebaking the feed
body: false, // requires rebaking the feed
Expand Down
30 changes: 29 additions & 1 deletion adminSiteClient/gdocsValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function validateGrapherUrl(
gdoc: OwidGdocDataInsightInterface,
errors: OwidGdocErrorMessage[]
) {
if (!gdoc.content["grapher-url"]) {
if (!gdoc.content["narrative-chart"] && !gdoc.content["grapher-url"]) {
errors.push({
property: "grapher-url",
type: OwidGdocErrorMessageType.Warning,
Expand All @@ -199,6 +199,32 @@ function validateGrapherUrl(
}
}

function validateNarrativeChart(
gdoc: OwidGdocDataInsightInterface,
errors: OwidGdocErrorMessage[]
) {
if (!gdoc.content["narrative-chart"] && !gdoc.content["grapher-url"]) {
errors.push({
property: "narrative-chart",
type: OwidGdocErrorMessageType.Warning,
message: `Missing "narrative-chart". This isn't required, but if you're referencing a narrative chart, it's a good idea to add it so that we can link it to this data insight.`,
})
}
}

function validateFigmaUrl(
gdoc: OwidGdocDataInsightInterface,
errors: OwidGdocErrorMessage[]
) {
if (!gdoc.content["figma-url"]) {
errors.push({
property: "figma-url",
type: OwidGdocErrorMessageType.Warning,
message: `Missing "figma-url". This isn't required, but if you edited the chart in Figma, it's a good idea to share the URL so that we can link it to this data insight.`,
})
}
}

function validateDataInsightImage(
gdoc: OwidGdocDataInsightInterface,
errors: OwidGdocErrorMessage[]
Expand Down Expand Up @@ -296,7 +322,9 @@ export const getErrors = (gdoc: OwidGdoc): OwidGdocErrorMessage[] => {
validateAtomFields(gdoc, errors)
} else if (checkIsDataInsight(gdoc)) {
validateApprovedBy(gdoc, errors)
validateNarrativeChart(gdoc, errors)
validateGrapherUrl(gdoc, errors)
validateFigmaUrl(gdoc, errors)
validateDataInsightImage(gdoc, errors)
} else if (checkIsAuthor(gdoc)) {
validateSocials(gdoc, errors)
Expand Down
2 changes: 2 additions & 0 deletions packages/@ourworldindata/types/src/gdocTypes/Gdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ export function extractGdocIndexItem(
export interface OwidGdocDataInsightContent {
title: string
authors: string[]
["narrative-chart"]?: string
["grapher-url"]?: string
["figma-url"]?: string
["approved-by"]: string // can't publish an insight unless this is set
body: OwidEnrichedGdocBlock[]
type: OwidGdocType.DataInsight
Expand Down

0 comments on commit 439c38d

Please sign in to comment.