Skip to content

Commit

Permalink
Merge pull request #2761 from owid/fix-date-accessed-missing
Browse files Browse the repository at this point in the history
🐛 fix bug when rendering data page for indicator without origins
  • Loading branch information
danyx23 authored Oct 12, 2023
2 parents e41354f + 632cf1f commit a218c0b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions site/DataPageV2Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ export const DataPageV2Content = ({
const originsLong = datapageData.origins
.map((o) => `${o.producer}, ${o.title ?? o.titleSnapshot}`)
.join("; ")
const dateAccessed = datapageData.origins[0].dateAccessed
? dayjs(datapageData.origins[0].dateAccessed).format("MMMM D, YYYY")
: ""
const dateAccessed =
datapageData.origins &&
datapageData.origins.length &&
datapageData.origins[0].dateAccessed
? dayjs(datapageData.origins[0].dateAccessed).format("MMMM D, YYYY")
: ""
const urlAccessed = datapageData.origins[0].urlDownload
const citationLong = `${citationShort}. ${datapageData.title}. ${originsLong}, ${processedAdapted} by Our World In Data. Retrieved ${dateAccessed} from ${urlAccessed}`
const processedAdaptedText =
Expand Down

0 comments on commit a218c0b

Please sign in to comment.