<commit_before>import React from 'react';
import RehypeReact from 'rehype-react';
import _ from 'lodash';
import config from '../../data/SiteConfig';
import SEO from '../components/SEO';
import AsideMenu from '../components/AsideMenu';
import AcademyLink from '../componentsMarkdown/AcademyLink';
import Callout from '../componentsMarkdown/Callout';
import Gist from '../componentsMarkdown/Gist';
import CodeGroup from '../componentsMarkdown/CodeGroup';
import withSubNav from '../components/NavSub';
import './syntax-highlighting.scss';
import './doc.scss';

const renderAst = new RehypeReact({
  createElement: React.createElement,
  components: {
    gist: Gist,
    'academy-link': AcademyLink,
    'call-out': Callout,
    'code-group': CodeGroup,
  },
}).Compiler;

class DocTemplate extends React.Component {
  getLinks() {
    const headers = this.props.data.doc.htmlAst.children.filter(el => el.type === 'element' && _.includes(['h2', 'h3'], el.tagName));
    return headers.map((header) => {
      const link = {};
      link.tagName = header.tagName;
      link.textNode = header.children[1] ? header.children[1].value : '';
      link.id = header.properties.id;
      return link;
    });
  }

  getRepoLink() {
    const {
      permalink,
      slug,
    } = this.props.data.doc.fields;

    const absPath = this.props.data.doc.fileAbsolutePath;
    const filename = absPath.substring(absPath.lastIndexOf('/') + 1);
    const fileSlug = filename.replace('.md', '');
    const path = permalink.replace(`${fileSlug}/`, '');
    const gitHubURL = config.gitHubMarkdownPath + path + filename;

    return gitHubURL;
  }

  render() {
    const postNode = this.props.data.doc;
    const asideLinks = this.getLinks();

    return (
      <div className="container-lg doc-wrap">
        <SEO postNode={postNode} postType="doc" />
        {postNode.fields.docType !== 'glossary' && asideLinks.length ?
         (<AsideMenu asideLinks={this.getLinks()} />)
         : null
        }
        <div className="doc-main"><commit_msg>remove slug var<commit_after>import React from 'react';
import RehypeReact from 'rehype-react';
import _ from 'lodash';
import config from '../../data/SiteConfig';
import SEO from '../components/SEO';
import AsideMenu from '../components/AsideMenu';
import AcademyLink from '../componentsMarkdown/AcademyLink';
import Callout from '../componentsMarkdown/Callout';
import Gist from '../componentsMarkdown/Gist';
import CodeGroup from '../componentsMarkdown/CodeGroup';
import withSubNav from '../components/NavSub';
import './syntax-highlighting.scss';
import './doc.scss';

const renderAst = new RehypeReact({
  createElement: React.createElement,
  components: {
    gist: Gist,
    'academy-link': AcademyLink,
    'call-out': Callout,
    'code-group': CodeGroup,
  },
}).Compiler;

class DocTemplate extends React.Component {
  getLinks() {
    const headers = this.props.data.doc.htmlAst.children.filter(el => el.type === 'element' && _.includes(['h2', 'h3'], el.tagName));
    return headers.map((header) => {
      const link = {};
      link.tagName = header.tagName;
      link.textNode = header.children[1] ? header.children[1].value : '';
      link.id = header.properties.id;
      return link;
    });
  }

  getRepoLink() {
    const {
      permalink,
    } = this.props.data.doc.fields;

    const absPath = this.props.data.doc.fileAbsolutePath;
    const filename = absPath.substring(absPath.lastIndexOf('/') + 1);
    const fileSlug = filename.replace('.md', '');
    const path = permalink.replace(`${fileSlug}/`, '');
    const gitHubURL = config.gitHubMarkdownPath + path + filename;

    return gitHubURL;
  }

  render() {
    const postNode = this.props.data.doc;
    const asideLinks = this.getLinks();

    return (
      <div className="container-lg doc-wrap">
        <SEO postNode={postNode} postType="doc" />
        {postNode.fields.docType !== 'glossary' && asideLinks.length ?
         (<AsideMenu asideLinks={this.getLinks()} />)
         : null
        }
        <div className="doc-main">
{'fraction_non_alphanumeric': 0.1554953178905865, 'fraction_numerical': 0.0024642681123706258, 'mean_word_length': 3.3089171974522293, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5072091', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1240, 'n_words': 272}