<commit_before>const fs = require(`fs`);
const glob = require(`glob`);
const path = require(`path`);

const buildHtml = require(`./_build-html.js`);

const pages = glob.sync(path.join(process.cwd(), `pages`, `**`, `*.hbs`));

module.exports = (data) => {
  pages.forEach((page) => {
    const baseTemplate = fs.readFileSync(page, `utf8`);
    const outputFile = path.join(process.cwd(), `dist`, `${path.parse(page).name}.html`);
    buildHtml(baseTemplate, data, outputFile);
  });
};<commit_msg>Add support for nested pages<commit_after>const fs = require(`fs`);
const glob = require(`glob`);
const path = require(`path`);

const buildHtml = require(`./_build-html.js`);

const pages = glob.sync(path.join(process.cwd(), `pages`, `**`, `*.hbs`));

module.exports = (data) => {
  pages.forEach((page) => {
    const baseTemplate = fs.readFileSync(page, `utf8`);
    const pathName = path.parse(page).name;
    const subPath = path
      .parse(page.replace(path.join(process.cwd(), `pages`, path.sep), ``))
      .dir.split(path.sep);
    const outputPath = [process.cwd(), `dist`, ...subPath];
    if (pathName !== `index`) {
      outputPath.push(pathName);
    }
    const outputFile = path.join(...outputPath, `index.html`);
    buildHtml(baseTemplate, data, outputFile);
  });
};
{'fraction_non_alphanumeric': 0.2087227414330218, 'fraction_numerical': 0.001557632398753894, 'mean_word_length': 4.244897959183674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3192013', 'n_tokens_mistral': 423, 'n_tokens_neox': 435, 'n_words': 86}