<commit_before>const path = require('path');
const slash = require('slash');
const {kebabCase, uniq, get, compact, times} = require('lodash');

// Don't forget to update hard code values into:
// - `templates/blog-page.tsx:23`
// - `pages/blog.tsx:26`
// - `pages/blog.tsx:121`
const POSTS_PER_PAGE = 10;
const cleanArray = arr => compact(uniq(arr));

// Create slugs for files.
// Slug will used for blog page path.
exports.onCreateNode = ({node, actions, getNode}) => {
  const {createNodeField} = actions;
  let slug;
  switch (node.internal.type) {
    case `MarkdownRemark`:
      const fileNode = getNode(node.parent);
      const [basePath, name] = fileNode.relativePath.split('/');
      slug = `/${basePath}/${name}/`;
      break;
  }
  if (slug) {
    createNodeField({node, name: `slug`, value: slug});
  }
};

const createDraftBlogPages = (graphql, createPage) => {
  const template = path.resolve(`src/templates/${kebabCase('blogPost')}.tsx`);
  return graphql(
    `
      {
        posts: allMarkdownRemark(
          filter: {
            frontmatter: {
              draft: { eq: true }
            },
            fileAbsolutePath: {regex: "/blog/"},
          }
        ) {
          edges {
            node {
              fields {
                slug
              }
            }
          }
        }
      }
    `
  ).then(result => {
    const posts = result.data.posts.edges.map(p => p.node);

    posts.filter(post => post.fields.slug.startsWith('/blog/')).forEach(post => {
      createPage({<commit_msg>fixing draft blog generation when there are no draft blog posts<commit_after>const path = require('path');
const slash = require('slash');
const {kebabCase, uniq, get, compact, times} = require('lodash');

// Don't forget to update hard code values into:
// - `templates/blog-page.tsx:23`
// - `pages/blog.tsx:26`
// - `pages/blog.tsx:121`
const POSTS_PER_PAGE = 10;
const cleanArray = arr => compact(uniq(arr));

// Create slugs for files.
// Slug will used for blog page path.
exports.onCreateNode = ({node, actions, getNode}) => {
  const {createNodeField} = actions;
  let slug;
  switch (node.internal.type) {
    case `MarkdownRemark`:
      const fileNode = getNode(node.parent);
      const [basePath, name] = fileNode.relativePath.split('/');
      slug = `/${basePath}/${name}/`;
      break;
  }
  if (slug) {
    createNodeField({node, name: `slug`, value: slug});
  }
};

const createDraftBlogPages = (graphql, createPage) => {
  const template = path.resolve(`src/templates/${kebabCase('blogPost')}.tsx`);
  return graphql(
    `
      {
        posts: allMarkdownRemark(
          filter: {
            frontmatter: {
              draft: { eq: true }
            },
            fileAbsolutePath: {regex: "/blog/"},
          }
        ) {
          edges {
            node {
              fields {
                slug
              }
            }
          }
        }
      }
    `
  ).then(result => {
    if (result.data.posts === null) {
      return;
    }
    const posts = result.data.posts.edges.map(p => p.node);

    posts.filter(post => post.fields.slug.startsWith('/blog/')).forEach(post => {
      createPage({
{'fraction_non_alphanumeric': 0.1561712846347607, 'fraction_numerical': 0.005667506297229219, 'mean_word_length': 2.1833667334669338, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '2794855', 'n_tokens_mistral': 1030, 'n_tokens_neox': 1009, 'n_words': 219}