<commit_before>import React from "react";
import H from "react-helmet";
import { StaticQuery, graphql } from "gatsby";

interface IProps {
  description: string;
  lang: string;
  meta: { name: string; content: string }[];
  keywords: string[];
  title: string;
  image: string | null;
}

const Helmet: any = H;

function SEO({
  description = null,
  lang = "en",
  meta = [],
  keywords = [],
  title = null,
  image = null,
}: Partial<IProps>) {
  return (
    <StaticQuery
      query={detailsQuery}
      render={(data) => {
        const siteMetadata = data.site.siteMetadata;
        const metaDescription = description ?? siteMetadata.description;
        const siteLink = `${siteMetadata.siteUrl}${
          typeof window !== "undefined" ? window.location.pathname : ""
        }`;

        return (
          <Helmet
            title={title ?? siteMetadata.title}
            titleTemplate={`%s | ${siteMetadata.title}`}
            link={[
              {
                rel: "canonical",
                key: siteLink,
                href: siteLink,
              },
            ]}
            meta={[
              {
                name: `description`,
                content: metaDescription,
              },
              {
                property: `og:title`,
                content: siteMetadata.title,
              },
              {
                property: `og:description`,
                content: metaDescription,
              },
              {
                property: `og:type`,
                content: `website`,
              },
              {
                property: `og:url`,
                content: siteLink,
              },
              {
                name: `twitter:creator`,
                content: siteMetadata.author,
              },
              {
                name: `twitter:title`,
                content: title,
              },
              {
                name: `twitter:description`,
                content: metaDescription,
              },
              {
                name: `keywords`,
                content: keywords.concat(siteMetadata.keywords).join(`, `),
              },
            ]
              .concat(
                image
                  ? [
                      {
                        name: `twitter:image`,
                        content: image,
                      },
                      {
                        name: `og:image`,
                        content: image,
                      },
                      {
                        name: `twitter:card`,
                        content: `summary_large_image`,
                      },
                    ]
                  : [
                      {
                        name: `twitter:card`,
                        content: `summary`,
                      },
                    ]
              )
              .concat(meta)}
          >
            <html lang={lang ?? "en"} />
          </Helmet>
        );
      }}
    />
  );
}
export default SEO;

const detailsQuery = graphql`
  query DefaultSEOQuery {
    site {
      siteMetadata {<commit_msg>feat: add plausible<commit_after>import React from "react";
import H from "react-helmet";
import { StaticQuery, graphql } from "gatsby";

interface IProps {
  description: string;
  lang: string;
  meta: { name: string; content: string }[];
  keywords: string[];
  title: string;
  image: string | null;
}

const Helmet: any = H;

function SEO({
  description = null,
  lang = "en",
  meta = [],
  keywords = [],
  title = null,
  image = null,
}: Partial<IProps>) {
  return (
    <StaticQuery
      query={detailsQuery}
      render={(data) => {
        const siteMetadata = data.site.siteMetadata;
        const metaDescription = description ?? siteMetadata.description;
        const siteLink = `${siteMetadata.siteUrl}${typeof window !== "undefined" ? window.location.pathname : ""}`;

        return (
          <Helmet
            title={title ?? siteMetadata.title}
            titleTemplate={`%s | ${siteMetadata.title}`}
            link={[
              {
                rel: "canonical",
                key: siteLink,
                href: siteLink,
              },
            ]}
            meta={[
              {
                name: `description`,
                content: metaDescription,
              },
              {
                property: `og:title`,
                content: siteMetadata.title,
              },
              {
                property: `og:description`,
                content: metaDescription,
              },
              {
                property: `og:type`,
                content: `website`,
              },
              {
                property: `og:url`,
                content: siteLink,
              },
              {
                name: `twitter:creator`,
                content: siteMetadata.author,
              },
              {
                name: `twitter:title`,
                content: title,
              },
              {
                name: `twitter:description`,
                content: metaDescription,
              },
              {
                name: `keywords`,
                content: keywords.concat(siteMetadata.keywords).join(`, `),
              },
            ]
              .concat(
                image
                  ? [
                      {
                        name: `twitter:image`,
                        content: image,
                      },
                      {
                        name: `og:image`,
                        content: image,
                      },
                      {
                        name: `twitter:card`,
                        content: `summary_large_image`,
                      },
                    ]
                  : [
                      {
                        name: `twitter:card`,
                        content: `summary`,
                      },
                    ]
              )
              .concat(meta)}
          >
            <html lang={lang ?? "en"} />

            <script async defer data-domain="dylanpaulus.com" src="https://plausible.io/js/plausible.js"></script>
          </Helmet>
        );
      }}
    />
  );
}
export default SEO;

const detailsQuery = graphql`
  query DefaultSEOQuery {
    site {
      siteMetadata {
{'fraction_non_alphanumeric': 0.10959548447789276, 'fraction_numerical': 0.0, 'mean_word_length': 0.973700495049505, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 1, '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': '2189362', 'n_tokens_mistral': 1567, 'n_tokens_neox': 1472, 'n_words': 304}