Skip to content

Commit

Permalink
fix(byline): make linkedAuthor optional in context
Browse files Browse the repository at this point in the history
  • Loading branch information
mlbrgl committed May 22, 2024
1 parent d97eb97 commit 64874f2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions adminSiteClient/gdocsDeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const checkIsLightningUpdate = (
> = {
breadcrumbs: true,
errors: true,
linkedAuthors: false,
linkedCharts: true,
linkedIndicators: true,
linkedDocuments: true,
Expand Down
3 changes: 2 additions & 1 deletion baker/SiteBaker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,8 @@ export class SiteBaker {
dataInsight.linkedChartSlugs.grapher,
dataInsight.linkedChartSlugs.explorer,
])
dataInsight.linkedAuthors = attachments.linkedAuthors
// Not used just yet
// dataInsight.linkedAuthors = attachments.linkedAuthors
dataInsight.linkedDocuments = attachments.linkedDocuments
dataInsight.imageMetadata = attachments.imageMetadata
dataInsight.linkedCharts = {
Expand Down
2 changes: 1 addition & 1 deletion site/gdocs/OwidGdoc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Homepage } from "./pages/Homepage.js"
import { Author } from "./pages/Author.js"

export const AttachmentsContext = createContext<{
linkedAuthors: DbEnrichedAuthor[]
linkedAuthors?: DbEnrichedAuthor[]
linkedCharts: Record<string, LinkedChart>
linkedIndicators: Record<number, LinkedIndicator>
linkedDocuments: Record<string, OwidGdocMinimalPostInterface>
Expand Down
2 changes: 1 addition & 1 deletion site/gdocs/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const breadcrumbColorForCoverColor = (

export const useLinkedAuthor = (name: string): DbEnrichedAuthor => {
const { linkedAuthors } = useContext(AttachmentsContext)
const author = linkedAuthors.find((author) => author.title === name)
const author = linkedAuthors?.find((author) => author.title === name)
if (!author) return { title: name, slug: null }
return author
}
Expand Down

0 comments on commit 64874f2

Please sign in to comment.