<commit_before>import React from 'react';
import DocumentTitle from 'react-document-title';
import last from 'lodash/last';

import { prefixLink } from 'gatsby-helpers';
import { config } from 'config';
import piwikConfig from 'piwik';

import { TypographyStyle } from 'src/util/typography';
import generateMetaTags from 'src/util/generateMetaTags';


const now = new Date();
const buster = now.getTime();

export default function HTML(props) {
  const buildMode = Boolean(props.body);

  const post = props.routes ? last(props.routes).page : null;
  const path = props.location ? props.location.pathname : null;
  const metaTags = generateMetaTags(post, config, path);

  const title = DocumentTitle.rewind() || config.blogTitle;
  const piwikSetup = buildPiwikSetup(config, piwikConfig);
  const piwikNoScript = buildPiwikNoScript(path, config.domain, piwikConfig);
  const js = getJS(buildMode, config.noProductionJavascript);
  const css = getCSS(buildMode);

  const { favicon } = config;

  return <html lang="en">
    <head>
      <title>{title}</title>
      <meta charSet="utf-8" />
      <meta httpEquiv="X-UA-Compatible" content="IE=edge" />
      <meta name="viewport" content="initial-scale=1.0" />
      {metaTags}
      <link rel="shortcut icon" href={favicon} />
      <TypographyStyle />
      {css}
    </head>
    <body className="landing-page">
      <div id="react-mount" dangerouslySetInnerHTML={{ __html: props.body }} />
      {js}
      {piwikSetup}
      {piwikNoScript}
    </body>
  </html>;
}

HTML.propTypes = {
  body: React.PropTypes.string,
  location: React.PropTypes.object,
  routes: React.PropTypes.array,
};

function buildPiwikSetup({ domainCDN }, { domain, siteId, site }) {
  const js = `
    window._paq = window._paq || [];
    window._paq.push(['setTrackerUrl', '${domain}/piwik.php']);
    window._paq.push(['setSiteId', '${siteId}']);
    window._paq.push(['setCookieDomain', '${site}']);
    window._paq.push(['setDomains', ['${site}']]);
    window._paq.push(['enableLinkTracking']);
    window._paq.push(['trackPageView']);
    window._paq.push(['enableHeartBeatTimer']);

    window.start = new Date();

    // add tag
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.defer=true; g.async=true;
    g.src='${domainCDN}/js/piwik/2.15.0/piwik.min.js';
    s.parentNode.insertBefore(g,s);
  `;

  return <script
    type="text/javascript"
    dangerouslySetInnerHTML={{ __html: js }}
  />;
}

buildPiwikSetup.propTypes = {
  domainCDN: React.PropTypes.string,
  domainPiwik: React.PropTypes.string,
};


function buildPiwikNoScript(path, blogDomain, { domain }) {
  const encodedPath = encodeURIComponent(blogDomain + path);

  return <noscript>
    <img
      src={`${domain}/piwik.php?idsite=3&rec=1&url=${encodedPath}`}
      style={{ border: 0 }}
      alt="tracker"
    />
  </noscript>;
}

function getJS(buildMode, noProductionJavascript) {
  const bundle = <script async defer src={prefixLink(`/bundle.js?t=${buster}`)} />;

  if (buildMode && noProductionJavascript) {
    return null;
  }

  return bundle;
}

function getCSS(buildMode) {
  const stylesheet =
    <link rel="stylesheet" href={prefixLink(`/styles.css?t=${buster}`)} />;

  if (buildMode) {
    return stylesheet;
  }

  return null;
}
<commit_msg>chore(SEO): Add bing site validation<commit_after>import React from 'react';
import DocumentTitle from 'react-document-title';
import last from 'lodash/last';

import { prefixLink } from 'gatsby-helpers';
import { config } from 'config';
import piwikConfig from 'piwik';

import { TypographyStyle } from 'src/util/typography';
import generateMetaTags from 'src/util/generateMetaTags';


const now = new Date();
const buster = now.getTime();

export default function HTML(props) {
  const buildMode = Boolean(props.body);

  const post = props.routes ? last(props.routes).page : null;
  const path = props.location ? props.location.pathname : null;
  const metaTags = generateMetaTags(post, config, path);

  const title = DocumentTitle.rewind() || config.blogTitle;
  const piwikSetup = buildPiwikSetup(config, piwikConfig);
  const piwikNoScript = buildPiwikNoScript(path, config.domain, piwikConfig);
  const js = getJS(buildMode, config.noProductionJavascript);
  const css = getCSS(buildMode);

  const { favicon } = config;

  return <html lang="en">
    <head>
      <title>{title}</title>
      <meta charSet="utf-8" />
      <meta httpEquiv="X-UA-Compatible" content="IE=edge" />
      <meta name="viewport" content="initial-scale=1.0" />
      <meta name="msvalidate.01" content="C9F5166E8EC2D15AD50586E58B77F82D" />
      {metaTags}
      <link rel="shortcut icon" href={favicon} />
      <TypographyStyle />
      {css}
    </head>
    <body className="landing-page">
      <div id="react-mount" dangerouslySetInnerHTML={{ __html: props.body }} />
      {js}
      {piwikSetup}
      {piwikNoScript}
    </body>
  </html>;
}

HTML.propTypes = {
  body: React.PropTypes.string,
  location: React.PropTypes.object,
  routes: React.PropTypes.array,
};

function buildPiwikSetup({ domainCDN }, { domain, siteId, site }) {
  const js = `
    window._paq = window._paq || [];
    window._paq.push(['setTrackerUrl', '${domain}/piwik.php']);
    window._paq.push(['setSiteId', '${siteId}']);
    window._paq.push(['setCookieDomain', '${site}']);
    window._paq.push(['setDomains', ['${site}']]);
    window._paq.push(['enableLinkTracking']);
    window._paq.push(['trackPageView']);
    window._paq.push(['enableHeartBeatTimer']);

    window.start = new Date();

    // add tag
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.defer=true; g.async=true;
    g.src='${domainCDN}/js/piwik/2.15.0/piwik.min.js';
    s.parentNode.insertBefore(g,s);
  `;

  return <script
    type="text/javascript"
    dangerouslySetInnerHTML={{ __html: js }}
  />;
}

buildPiwikSetup.propTypes = {
  domainCDN: React.PropTypes.string,
  domainPiwik: React.PropTypes.string,
};


function buildPiwikNoScript(path, blogDomain, { domain }) {
  const encodedPath = encodeURIComponent(blogDomain + path);

  return <noscript>
    <img
      src={`${domain}/piwik.php?idsite=3&rec=1&url=${encodedPath}`}
      style={{ border: 0 }}
      alt="tracker"
    />
  </noscript>;
}

function getJS(buildMode, noProductionJavascript) {
  const bundle = <script async defer src={prefixLink(`/bundle.js?t=${buster}`)} />;

  if (buildMode && noProductionJavascript) {
    return null;
  }

  return bundle;
}

function getCSS(buildMode) {
  const stylesheet =
    <link rel="stylesheet" href={prefixLink(`/styles.css?t=${buster}`)} />;

  if (buildMode) {
    return stylesheet;
  }

  return null;
}

{'fraction_non_alphanumeric': 0.16204659392509585, 'fraction_numerical': 0.006487761722205839, 'mean_word_length': 3.998526160648489, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 44, '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': '6750547', 'n_tokens_mistral': 2315, 'n_tokens_neox': 2264, 'n_words': 439}