<commit_before>'use strict';

const React = require('react');
const chain = require('ramda/src/chain');
const toReactComponent = require('jsonml-to-react-component');
const exist = require('exist.js');
const NotFound = require('{{ themePath }}/template/NotFound');
const data = require('./data.js');
const NProgress = require('nprogress');
require('nprogress/nprogress.css');

const plugins = data.plugins;
const converters = chain((plugin) => plugin.converters || [], plugins);
const utils = {
  get: exist.get,
  toReactComponent(jsonml) {
    return toReactComponent(jsonml, converters);
  },
};
plugins.map((plugin) => plugin.utils || {})
  .forEach((u) => Object.assign(utils, u));

function calcPropsPath(dataPath, params) {
  return Object.keys(params).reduce(
    (path, param) => path.replace(`:${param}`, params[param]),
    dataPath
  );
}

function hasParams(dataPath) {
  return dataPath.split('/').some((snippet) => snippet.startsWith(':'));
}

function defaultCollect(nextProps, callback) {
  callback(null, nextProps);
}
module.exports = function templateWrapper(template, dataPath = '') {
  const Template = require(`{{ themePath }}/${template.replace(/^\.\//, '')}`);

  return (nextState, callback) => {
    const propsPath = calcPropsPath(dataPath, nextState.params);<commit_msg>fix: make require.context filter more strictly, close: #30<commit_after>'use strict';

const React = require('react');
const chain = require('ramda/src/chain');
const toReactComponent = require('jsonml-to-react-component');
const exist = require('exist.js');
const NotFound = require('{{ themePath }}/template/NotFound');
const data = require('./data.js');
const NProgress = require('nprogress');
require('nprogress/nprogress.css');

const plugins = data.plugins;
const converters = chain((plugin) => plugin.converters || [], plugins);
const utils = {
  get: exist.get,
  toReactComponent(jsonml) {
    return toReactComponent(jsonml, converters);
  },
};
plugins.map((plugin) => plugin.utils || {})
  .forEach((u) => Object.assign(utils, u));

function calcPropsPath(dataPath, params) {
  return Object.keys(params).reduce(
    (path, param) => path.replace(`:${param}`, params[param]),
    dataPath
  );
}

function hasParams(dataPath) {
  return dataPath.split('/').some((snippet) => snippet.startsWith(':'));
}

function defaultCollect(nextProps, callback) {
  callback(null, nextProps);
}
module.exports = function templateWrapper(template, dataPath = '') {
  const Template = require(`{{ themePath }}/template${template.replace(/^\.\/template/, '')}`);

  return (nextState, callback) => {
    const propsPath = calcPropsPath(dataPath, nextState.params);
{'fraction_non_alphanumeric': 0.18089507333584054, 'fraction_numerical': 0.000752162467092892, 'mean_word_length': 5.503667481662592, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5998561', 'n_tokens_mistral': 791, 'n_tokens_neox': 799, 'n_words': 172}