Skip to content

Commit

Permalink
🎉 (gdocs) add optional Source overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Jan 30, 2024
1 parent 725d84b commit 503f01c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions db/model/Gdoc/enrichedToMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ ${links}`
{
datapageUrl: b.datapageUrl,
title: b.title,
source: b.source,
// blurb ignored
},
exportComponents
Expand Down
1 change: 1 addition & 0 deletions db/model/Gdoc/enrichedToRaw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ export function enrichedBlockToRawBlock(
value: spansToHtmlText(enriched.value),
}))
: undefined,
source: b.source,
},
}
})
Expand Down
1 change: 1 addition & 0 deletions db/model/Gdoc/rawToArchie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,7 @@ function* rawBlockKeyIndicatorToArchieMLString(
if (typeof block.value !== "string") {
yield* propertyToArchieMLString("datapageUrl", block.value)
yield* propertyToArchieMLString("title", block.value)
yield* propertyToArchieMLString("source", block.value)
if (block.value.blurb) {
yield "[.+blurb]"
for (const textBlock of block.value.blurb) {
Expand Down
1 change: 1 addition & 0 deletions db/model/Gdoc/rawToEnriched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,7 @@ const parseKeyIndicator = (
datapageUrl: url,
blurb: parsedBlurb.length > 0 ? parsedBlurb : undefined,
title: val.title,
source: val.source,
parseErrors: parsedBlurbErrors,
}) as EnrichedBlockKeyIndicator
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export type RawBlockKeyIndicatorValue = {
datapageUrl?: string
title?: string
blurb?: RawBlockText[]
source?: string
}

export type RawBlockKeyIndicator = {
Expand All @@ -102,6 +103,7 @@ export type EnrichedBlockKeyIndicator = {
datapageUrl: string
title?: string
blurb?: EnrichedBlockText[]
source?: string
} & EnrichedBlockWithParseErrors

export type RawBlockScroller = {
Expand Down
12 changes: 7 additions & 5 deletions site/gdocs/components/KeyIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ export default function KeyIndicator({
if (!linkedChart) return null
if (!linkedIndicator) return null

const source = capitalize(
joinTitleFragments(
linkedIndicator.attributionShort,
linkedIndicator.titleVariant
const source =
d.source ||
capitalize(
joinTitleFragments(
linkedIndicator.attributionShort,
linkedIndicator.titleVariant
)
)
)
const dateRange = makeDateRange({
dateRange: linkedIndicator.dateRange,
})
Expand Down

0 comments on commit 503f01c

Please sign in to comment.