Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { WORDPRESS_URL } from "../settings/serverSettings"
import * as React from "react"
import { Head } from "./Head"
import { CitationMeta } from "./CitationMeta"
import { SiteHeader } from "./SiteHeader"
import { SiteFooter } from "./SiteFooter"
import { addContentFeatures, formatAuthors } from "../site/formatting"
import { SiteSubnavigation } from "./SiteSubnavigation"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faBook } from "@fortawesome/free-solid-svg-icons/faBook"
import { faSync } from "@fortawesome/free-solid-svg-icons/faSync"
import { faCreativeCommons } from "@fortawesome/free-brands-svg-icons/faCreativeCommons"
import { TableOfContents } from "../site/TableOfContents"
import {
FormattedPost,
FormattingOptions,
TocHeading,
} from "../clientUtils/owidTypes"
import { Breadcrumb } from "./Breadcrumb/Breadcrumb"
import { Byline } from "./Byline"
import { PageInfo } from "./PageInfo"
import { BackToTopic } from "./BackToTopic"
export interface PageOverrides {
pageTitle?: string
pageDesc?: string
canonicalUrl?: string
citationTitle?: string
citationSlug?: string
citationCanonicalUrl?: string
citationAuthors?: string[]
citationPublicationDate?: Date
}
export const LongFormPage = (props: {
withCitation: boolean
post: FormattedPost
overrides?: PageOverrides
formattingOptions: FormattingOptions
baseUrl: string
}) => {
const { withCitation, post, overrides, formattingOptions, baseUrl } = props
const isPost = post.type === "post"
const pageTitle = overrides?.pageTitle ?? post.title
const pageTitleSEO = `${pageTitle}${
post.supertitle ? ` - ${post.supertitle}` : ""
}`
const pageDesc = overrides?.pageDesc ?? post.pageDesc
const canonicalUrl = overrides?.canonicalUrl ?? `${baseUrl}/${post.slug}`
const citationTitle = overrides?.citationTitle ?? pageTitle
const citationSlug = overrides?.citationSlug ?? post.slug
const citationCanonicalUrl = overrides?.citationCanonicalUrl ?? canonicalUrl
const citationPublicationDate =
overrides?.citationPublicationDate ?? post.date
const citationPublishedYear = citationPublicationDate.getFullYear()
const citationAuthors = overrides?.citationAuthors ?? post.authors
const citationAuthorsFormatted = formatAuthors(
citationAuthors,
withCitation
)
let hasSidebar = false
const endNotes = { text: "Endnotes", slug: "endnotes" }
const tocHeadings: TocHeading[] = [...post.tocHeadings]
if (tocHeadings.some((tocHeading) => !tocHeading.isSubheading)) {
hasSidebar = true
if (post.footnotes.length) {
tocHeadings.push({
...endNotes,
isSubheading: false,
})
}
if (withCitation) {
tocHeadings.push(
{
text: "Licence",
slug: "licence",
isSubheading: false,
},
{
text: "Citation",
slug: "citation",
isSubheading: false,
}
)
}
}
const bodyClasses = []
if (formattingOptions.bodyClassName) {
bodyClasses.push(formattingOptions.bodyClassName)
}
const bibtex = `@article{owid${citationSlug.replace(/-/g, "")},
author = {${citationAuthorsFormatted}},
title = {${citationTitle}},
journal = {Our World in Data},
year = {${citationPublishedYear}},
note = {${citationCanonicalUrl}}
}`
return (
<html>
<Head
pageTitle={pageTitleSEO}
pageDesc={pageDesc}
canonicalUrl={canonicalUrl}
imageUrl={post.imageUrl}
baseUrl={baseUrl}
>
{withCitation && (
<CitationMeta
title={citationTitle}
authors={citationAuthors}
date={citationPublicationDate}
canonicalUrl={citationCanonicalUrl}
/>
)}
{post.style && <style>{post.style}</style>}
</Head>
<body className={bodyClasses.join(" ")}>
<SiteHeader baseUrl={baseUrl} />
<main>
<article
className={`page${
hasSidebar ? " with-sidebar" : " no-sidebar"
}${isPost ? " thin-banner" : " large-banner"}`}
>
<div className="offset-header">
<header className="article-header">
{isPost && formattingOptions.subnavId && (
<BackToTopic
subnavId={formattingOptions.subnavId}
/>
)}
<div className="article-titles">
{post.supertitle && (
<div className="supertitle">
{post.supertitle}
</div>
)}
<h1 className="entry-title">{pageTitle}</h1>
{!isPost && formattingOptions.subnavId && (
<Breadcrumb
subnavId={
formattingOptions.subnavId
}
subnavCurrentId={
formattingOptions.subnavCurrentId
}
/>
)}
</div>
{!isPost && (
<>
{!formattingOptions.hideAuthors && (
<Byline
authors={post.authors}
withMax={withCitation}
override={post.byline}
/>
)}
{post.info && (
<PageInfo info={post.info} />
)}
{(withCitation || post.lastUpdated) && (
<div className="tools">
{post.lastUpdated && (
<div className="last-updated">
<FontAwesomeIcon
icon={faSync}
/>
<span
dangerouslySetInnerHTML={{
__html: post.lastUpdated,
}}
/>
</div>
)}
{withCitation && (
<>
<a href="#licence">
<FontAwesomeIcon
icon={
faCreativeCommons
}
/>
Reuse our work
freely
</a>
<a href="#citation">
<FontAwesomeIcon
icon={faBook}
/>
Cite this research
</a>
</>
)}
</div>
)}
</>
)}
</header>
</div>
{!isPost && formattingOptions.subnavId && (
<SiteSubnavigation
subnavId={formattingOptions.subnavId}
subnavCurrentId={
formattingOptions.subnavCurrentId
}
/>
)}
<div className="content-wrapper">
{hasSidebar && (
<TableOfContents
headings={tocHeadings}
pageTitle={pageTitle}
// hideSubheadings={true}
/>
)}
<div className="offset-content">
<div className="content-and-footnotes">
<div
className="article-content"
dangerouslySetInnerHTML={{
__html: addContentFeatures(post),
}}
/>
<footer className="article-footer">
<div className="wp-block-columns">
<div className="wp-block-column">
{isPost && post.info && (
<PageInfo
info={post.info}
/>
)}
{post.footnotes.length ? (
<React.Fragment>
<h3 id={endNotes.slug}>
{endNotes.text}
</h3>
<ol className="endnotes">
{post.footnotes.map(
(
footnote,
i
) => (
<li
key={i}
id={`note-${
i +
1
}`}
>
<p
dangerouslySetInnerHTML={{
__html: footnote,
}}
/>
</li>
)
)}
</ol>
</React.Fragment>
) : undefined}
{(isPost || withCitation) && (
<>
<h3 id="licence">
Reuse our work
freely
</h3>
<p>
All visualizations,
data, 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 noreferrer"
>
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.
</p>
<p>
The data produced by
third parties and
made available by
Our World in Data is
subject to the
license terms from
the original
third-party authors.
We will always
indicate the
original source of
the data in our
documentation, so
you should always
check the license of
any such third-party
data before use and
redistribution.
</p>
<p>
All of{" "}
<a href="/how-to-use-our-world-in-data#how-to-embed-interactive-charts-in-your-article">
our charts can
be embedded
</a>{" "}
in any site.
</p>
</>
)}
{withCitation && (
<>
<h3 id="citation">
Citation
</h3>
<p>
Our articles and
data visualizations
rely on work from
many different
people and
organizations. When
citing this entry,
please also cite the
underlying data
sources. This entry
can be cited as:
</p>
<pre className="citation">
{
citationAuthorsFormatted
}{" "}
(
{
citationPublishedYear
}
) - "{citationTitle}
".{" "}
<em>
Published online
at
OurWorldInData.org.
</em>{" "}
Retrieved from: '
{
citationCanonicalUrl
}
' [Online Resource]
</pre>
<p>BibTeX citation</p>
<pre className="citation">
{bibtex}
</pre>
</>
)}
</div>
<div className="wp-block-column"></div>
</div>
</footer>
</div>
</div>
</div>
</article>
</main>
<div id="wpadminbar" style={{ display: "none" }}>
<div
className="quicklinks"
id="wp-toolbar"
role="navigation"
aria-label="Toolbar"
>
<ul
id="wp-admin-bar-root-default"
className="ab-top-menu"
>
<li id="wp-admin-bar-site-name" className="menupop">
<a
className="ab-item"
aria-haspopup="true"
href={`${WORDPRESS_URL}/wp/wp-admin`}
>
Wordpress
</a>
</li>{" "}
<li id="wp-admin-bar-edit">
<a
className="ab-item"
href={formatWordpressEditLink(post.id)}
>
Edit Page
</a>
</li>
</ul>
</div>
</div>
<SiteFooter
hideDonate={formattingOptions.hideDonateFooter}
baseUrl={baseUrl}
/>
<script
dangerouslySetInnerHTML={{
__html: `
runTableOfContents(${JSON.stringify({
headings: tocHeadings,
pageTitle,
// hideSubheadings: true
})})
runRelatedCharts(${JSON.stringify(post.relatedCharts)})
`,
}}
/>
</body>
</html>
)
}
export const formatWordpressEditLink = (postId: number) => {
return `${WORDPRESS_URL}/wp/wp-admin/post.php?post=${postId}&action=edit`
}
|