<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { NavLink } from 'react-router-dom';

import { ListItem } from 'material-ui/List';

import { connect } from 'react-redux';
import { toggleSidebar } from '../../ducks/Sidebar';

import { isLarge } from '../Responsive';

const SidebarItem = ({ link, style, activeStyle, exact, sidebar, actions, children }) =>
  <NavLink
    to={link}
    style={{ ...styles().link, ...style }}
    activeStyle={{ ...styles().activeLink, ...activeStyle }}
    exact={exact}
    onClick={() => {
      if (!isLarge() && sidebar.visible) {
        actions.toggleSidebar();
      }
    }}
  >
    <ListItem style={styles().listItem}>
      {children}
    </ListItem>
  </NavLink>;

const styles = () => ({
  link: {
    transition: 'all 100ms linear',
    textDecoration: 'none',
  },
  activeLink: {
    display: 'block',
  },
  listItem: {
    color: 'inherit',
  },
});

SidebarItem.defaultProps = {
  style: {},
  activeStyle: {},
  exact: true,
};

SidebarItem.propTypes = {
  link: PropTypes.string.isRequired,
  style: PropTypes.object,
  activeStyle: PropTypes.object,
  exact: PropTypes.bool,
};

const mapStateToProps = state => ({
  sidebar: state.sidebar,
});

const mapDispatchToProps = dispatch => ({
  actions: {
    toggleSidebar: () => dispatch(toggleSidebar()),
  },
});

export default connect(mapStateToProps, mapDispatchToProps)(SidebarItem);<commit_msg>Add external link<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { NavLink } from 'react-router-dom';

import { ListItem } from 'material-ui/List';

import { connect } from 'react-redux';
import { toggleSidebar } from '../../ducks/Sidebar';

import { isLarge } from '../Responsive';

const SidebarItem = ({ link, style, activeStyle, exact, external, sidebar, actions, children }) => {
  if (external) {
    return (
      <a href={link} style={{ ...styles().link, ...style }}>
        <ListItem style={styles().listItem}>
          {children}
        </ListItem>
      </a>
    );
  }

  return (
    <NavLink
      to={link}
      style={{ ...styles().link, ...style }}
      activeStyle={{ ...styles().activeLink, ...activeStyle }}
      exact={exact}
      onClick={() => {
        if (!isLarge() && sidebar.visible) {
          actions.toggleSidebar();
        }
      }}
    >
      <ListItem style={styles().listItem}>
        {children}
      </ListItem>
    </NavLink>
  );
};

const styles = () => ({
  link: {
    transition: 'all 100ms linear',
    textDecoration: 'none',
  },
  activeLink: {
    display: 'block',
  },
  listItem: {
    color: 'inherit',
  },
});

SidebarItem.defaultProps = {
  style: {},
  activeStyle: {},
  exact: true,
  external: true,
};

SidebarItem.propTypes = {
  link: PropTypes.string.isRequired,
  style: PropTypes.object,
  activeStyle: PropTypes.object,
  exact: PropTypes.bool,
  external: PropTypes.bool,
};

const mapStateToProps = state => ({
  sidebar: state.sidebar,
});

const mapDispatchToProps = dispatch => ({
  actions: {
    toggleSidebar: () => dispatch(toggleSidebar()),
  },
});

export default connect(mapStateToProps, mapDispatchToProps)(SidebarItem);
{'fraction_non_alphanumeric': 0.17445873862566677, 'fraction_numerical': 0.0018826482585503608, 'mean_word_length': 3.1135483870967744, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, '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': '1351299', 'n_tokens_mistral': 1004, 'n_tokens_neox': 1010, 'n_words': 220}