<commit_before>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 { formatAuthors, formatDate } 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"

export interface PageOverrides {
    pageTitle?: string
    citationTitle?: string
    citationSlug?: string
    citationCanonicalUrl?: string
    citationAuthors?: string[]
    citationPublicationDate?: Date
    canonicalUrl?: string
    excerpt?: string
}

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?.excerpt ?? post.excerpt
    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={post.date}
                        canonicalUrl={citationCanonicalUrl}
                    />
                )}
            </Head>
            <body className={bodyClasses.join(" ")}><commit_msg>fix: use citationPublicationDate in CitationMeta<commit_after>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 { formatAuthors, formatDate } 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"

export interface PageOverrides {
    pageTitle?: string
    citationTitle?: string
    citationSlug?: string
    citationCanonicalUrl?: string
    citationAuthors?: string[]
    citationPublicationDate?: Date
    canonicalUrl?: string
    excerpt?: string
}

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?.excerpt ?? post.excerpt
    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}
                    />
                )}
            </Head>
            <body className={bodyClasses.join(" ")}>
{'fraction_non_alphanumeric': 0.10853086271206834, 'fraction_numerical': 0.0, 'mean_word_length': 2.277602523659306, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7281527', 'n_tokens_mistral': 2371, 'n_tokens_neox': 2186, 'n_words': 464}