-
-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathMetadataSection.tsx
212 lines (207 loc) · 9.88 KB
/
MetadataSection.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import dayjs from "dayjs"
import {
DATAPAGE_SOURCES_AND_PROCESSING_SECTION_ID,
IndicatorSources,
IndicatorProcessing,
CodeSnippet,
DataCitation,
} from "@ourworldindata/components"
import {
FaqEntryData,
OwidOrigin,
PrimaryTopic,
OwidSource,
IndicatorTitleWithFragments,
OwidProcessingLevel,
} from "@ourworldindata/types"
import {
prepareSourcesForDisplay,
getCitationShort,
getCitationLong,
excludeUndefined,
uniq,
} from "@ourworldindata/utils"
import { ArticleBlocks } from "./gdocs/components/ArticleBlocks.js"
export default function MetadataSection({
attributionShort,
attributions,
canonicalUrl,
descriptionProcessing,
faqEntries,
origins,
owidProcessingLevel,
primaryTopic,
source,
title,
titleVariant,
}: {
attributionShort?: string
attributions: string[]
canonicalUrl: string
descriptionProcessing?: string
faqEntries?: FaqEntryData
origins: OwidOrigin[]
owidProcessingLevel?: OwidProcessingLevel
primaryTopic?: PrimaryTopic
source?: OwidSource
title: IndicatorTitleWithFragments
titleVariant?: string
}) {
const sourcesForDisplay = prepareSourcesForDisplay({ origins, source })
const citationShort = getCitationShort(
origins,
attributions,
owidProcessingLevel
)
const citationLong = getCitationLong(
title,
origins,
source,
attributions,
attributionShort,
titleVariant,
owidProcessingLevel,
canonicalUrl
)
const currentYear = dayjs().year()
const producers = uniq(origins.map((o) => `${o.producer}`))
const adaptedFrom =
producers.length > 0 ? producers.join(", ") : source?.name
const maybeAddPeriod = (s: string) =>
s.endsWith("?") || s.endsWith(".") ? s : `${s}.`
// For the citation of the data page add a period it doesn't have that or a question mark
const primaryTopicCitation = maybeAddPeriod(primaryTopic?.citation ?? "")
const citationDatapage = excludeUndefined([
primaryTopic
? `“Data Page: ${title.title}”, part of the following publication: ${primaryTopicCitation}`
: `“Data Page: ${title.title}”. Our World in Data (${currentYear}).`,
adaptedFrom ? `Data adapted from ${adaptedFrom}.` : undefined,
`Retrieved from ${canonicalUrl} [online resource]`,
]).join(" ")
return (
<div className="MetadataSection span-cols-14 grid grid-cols-12-full-width">
<div className="col-start-2 span-cols-12">
{!!faqEntries?.faqs.length && (
<div className="section-wrapper section-wrapper__faqs grid">
<h2
className="faqs__title span-cols-2 span-lg-cols-3 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12"
id="faqs"
>
Frequently Asked Questions
</h2>
<div className="faqs__items grid grid-cols-10 grid-lg-cols-9 grid-md-cols-12 span-cols-10 span-lg-cols-9 span-md-cols-12 span-sm-cols-12">
<ArticleBlocks
blocks={faqEntries.faqs}
containerType="datapage"
/>
</div>
</div>
)}
<div className="section-wrapper grid">
<h2
className="data-sources-processing__title span-cols-2 span-lg-cols-3 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12"
id={DATAPAGE_SOURCES_AND_PROCESSING_SECTION_ID}
>
Sources and processing
</h2>
<div className="data-sources grid span-cols-12">
<h3 className="data-sources__heading span-cols-2 span-lg-cols-3 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12">
This data is based on the following sources
</h3>
<div className="col-start-4 span-cols-6 col-lg-start-5 span-lg-cols-7 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12">
<IndicatorSources sources={sourcesForDisplay} />
</div>
</div>
<div className="data-processing grid span-cols-12">
<h3 className="data-processing__heading span-cols-2 span-lg-cols-3 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12">
How we process data at Our World in Data
</h3>
<div className="col-start-4 span-cols-6 col-lg-start-5 span-lg-cols-7 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12">
<IndicatorProcessing
descriptionProcessing={descriptionProcessing}
/>
</div>
</div>
</div>
<div className="section-wrapper grid">
<h2
className="reuse__title span-cols-2 span-lg-cols-3 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12"
id="reuse-this-work"
>
Reuse this work
</h2>
<div className="col-start-4 span-cols-6 col-lg-start-5 span-lg-cols-7 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12">
<ul className="reuse__content">
<li className="reuse__list-item">
All data produced by third-party providers and
made available by Our World in Data are subject
to the license terms from the original
providers. Our work would not be possible
without the data providers we rely on, so we ask
you to always cite them appropriately (see
below). This is crucial to allow data providers
to continue doing their work, enhancing,
maintaining and updating valuable data.
</li>
<li className="reuse__list-item">
All data, visualizations, and code produced by
Our World in Data are completely open access
under the{" "}
<a
href="https://creativecommons.org/licenses/by/4.0/"
target="_blank"
rel="noopener"
className="reuse__link"
>
Creative Commons BY license
</a>
. You have the permission to use, distribute,
and reproduce these in any medium, provided the
source and authors are credited.
</li>
</ul>
</div>
{(citationShort || citationLong || citationDatapage) && (
<div className="citations grid span-cols-12">
<h3 className="citations__heading span-cols-2 span-lg-cols-3 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12">
Citations
</h3>
<div className="col-start-4 span-cols-6 col-lg-start-5 span-lg-cols-7 col-md-start-2 span-md-cols-10 col-sm-start-1 span-sm-cols-12">
{citationDatapage && (
<div className="citations-section">
<h5 className="citation__how-to-header">
How to cite this page
</h5>
<p className="citation__paragraph">
To cite this page overall, including
any descriptions, FAQs or
explanations of the data authored by
Our World in Data, please use the
following citation:
</p>
<CodeSnippet
code={citationDatapage}
theme="light"
useMarkdown={true}
/>
</div>
)}
<div className="citations-section">
<h5 className="citation__how-to-header citation__how-to-header--data">
How to cite this data
</h5>
{(citationShort || citationLong) && (
<DataCitation
citationLong={citationLong}
citationShort={citationShort}
/>
)}
</div>
</div>
</div>
)}
</div>
</div>
</div>
)
}