<commit_before>const { renderFile } = require('ejs')
const fs = require('fs')
const absoluteLinks = true
const href = path => (absoluteLinks ? '' : 'https://www.chippanfire.com/') + path
const renderPage = page => new Promise((resolve, reject) => {
  renderFile('templates/page.ejs', page, {}, (err, str) => err ? reject(err) : resolve({ content: str, file: page.file }))
})


const musicPage = {
  content: {
    title: 'Music'
  },
  href: href('music.html'),
  template: 'music'
}

const m4lPage = {
  content: {
    title: 'Max For Live Devices'
  },
  href: href('max-for-live-devices.html'),
  strapline: 'A collection of Max For Live devices I have made',
  template: 'm4l-devices'
}

const kmkScriptPage = {
  content: { title: 'KMK Control Script' },
  external: true,
  href: 'https://github.com/crosslandwa/kmkControl',
  strapline: 'In-depth control of Ableton Live using the Korg Microkontrol'
}

const cpfPage = {
  content: { title: 'ChipPanFire Source' },
  external: true,
  href: 'https://github.com/crosslandwa/chippanfire-site',
  strapline: 'Totally meta, see the source code for generating this site!'
}

const wacNetworkMidiPage = {
  content: { title: 'Wac Network MIDI' },
  href: href('wac-network-midi.html'),
  strapline: 'Cross-platform (Win/OS X) tool for transmitting MIDI between computers',
  template: 'content-wac-network-midi'
}

const softwarePage = {
  content: {
    linked: [ m4lPage, wacNetworkMidiPage, kmkScriptPage, cpfPage ],
    title: 'Software'
  },
  href: href('software.html'),
  template: 'software'
}

const homePage =  {
  content: {
    music: { href: musicPage.href },
    software: { href: softwarePage.href }
  },
  href: href('index.html'),
  template: 'index'
}

const contactPage = {
  content: { title: 'Contact' },
  href: href('contact.html'),
  template: 'contact'
}

const errorPage = {
  content: {
    title: 'Not Found 40404040404'
  },
  href: href('error.html'),
  template: 'error'
}

const navItem = page => Object.assign({ href: page.href, title: page.content.title, external: !!page.external })

const baseData = {
  assetsBaseUrl: href('assets'),
  image: path => `${href('assets/images')}/${path}`,
  navigation: {
    homePageUrl: homePage.href,
    items: [
      navItem(musicPage),
      Object.assign(navItem(softwarePage), { dropdown: softwarePage.content.linked.map(navItem) }),
      navItem(contactPage)
    ]
  }
}

const pages = [
  Object.assign({}, baseData, homePage, { file: 'index.html' }),
  Object.assign({}, baseData, errorPage, { file: 'error.html', scripts: ['assets/error-page.js']}),
  Object.assign({}, baseData, musicPage, { file: 'music.html' }),
  Object.assign({}, baseData, softwarePage, { file: 'software.html' }),
  Object.assign({}, baseData, m4lPage, { file: 'max-for-live-devices.html' }),
  Object.assign({}, baseData, contactPage, { file: 'contact.html' }),
  Object.assign({}, baseData, wacNetworkMidiPage, { file: 'wac-network-midi.html' }),
]

module.exports = {
  pages: pages.map(page => { return { file: page.file, scripts: page.scripts || [] } }),
  renderTemplates: () => Promise.all(pages.map(renderPage))
}<commit_msg>Remove duplication in declaring filename/href name<commit_after>const { renderFile } = require('ejs')
const fs = require('fs')
const absoluteLinks = true
const href = path => (absoluteLinks ? '' : 'https://www.chippanfire.com/') + path
const renderPage = page => new Promise((resolve, reject) => {
  renderFile('templates/page.ejs', page, {}, (err, str) => err ? reject(err) : resolve({ content: str, file: page.file }))
})


const musicPage = {
  content: {
    title: 'Music'
  },
  file: 'music.html',
  template: 'music'
}

const m4lPage = {
  content: {
    title: 'Max For Live Devices'
  },
  file: 'max-for-live-devices.html',
  strapline: 'A collection of Max For Live devices I have made',
  template: 'm4l-devices'
}

const kmkScriptPage = {
  content: { title: 'KMK Control Script' },
  external: true,
  href: 'https://github.com/crosslandwa/kmkControl',
  strapline: 'In-depth control of Ableton Live using the Korg Microkontrol'
}

const cpfPage = {
  content: { title: 'ChipPanFire Source' },
  external: true,
  href: 'https://github.com/crosslandwa/chippanfire-site',
  strapline: 'Totally meta, see the source code for generating this site!'
}

const wacNetworkMidiPage = {
  content: { title: 'Wac Network MIDI' },
  file: 'wac-network-midi.html',
  strapline: 'Cross-platform (Win/OS X) tool for transmitting MIDI between computers',
  template: 'content-wac-network-midi'
}

const softwarePage = {
  content: {
    linked: [ m4lPage, wacNetworkMidiPage, kmkScriptPage, cpfPage ],
    title: 'Software'
  },
  file: 'software.html',
  template: 'software'
}

const homePage =  {
  content: {
    music: { href: href(musicPage.file) },
    software: { href: href(softwarePage.file) }
  },
  file: 'index.html',
  template: 'index'
}

const contactPage = {
  content: { title: 'Contact' },
  file: 'contact.html',
  template: 'contact'
}

const errorPage = {
  content: {
    title: 'Not Found 40404040404'
  },
  file: 'error.html',
  scripts: ['assets/error-page.js'],
  template: 'error'
}

const navItem = page => Object.assign({ href: href(page.file), title: page.content.title, external: !!page.external })

const baseData = {
  assetsBaseUrl: href('assets'),
  image: path => `${href('assets/images')}/${path}`,
  navigation: {
    homePageUrl: href(homePage.file),
    items: [
      navItem(musicPage),
      Object.assign(navItem(softwarePage), { dropdown: softwarePage.content.linked.map(navItem) }),
      navItem(contactPage)
    ]
  }
}

const pages = [ homePage, errorPage, musicPage,
  softwarePage, m4lPage, contactPage, wacNetworkMidiPage ]
  .map(page => Object.assign({}, page, baseData, { href: href(page.file) }))

module.exports = {
  pages: pages.map(page => { return { file: page.file, scripts: page.scripts || [] } }),
  renderTemplates: () => Promise.all(pages.map(renderPage))
}
{'fraction_non_alphanumeric': 0.16459939658062353, 'fraction_numerical': 0.005028494803888703, 'mean_word_length': 4.061068702290076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, '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': '3252577', 'n_tokens_mistral': 2066, 'n_tokens_neox': 2030, 'n_words': 481}