var utils = require('../utils');
const path = require('path');
const basePath = process.cwd();

function Page (config, meta, parentKey) {
  this.meta = meta;
  
  this.key = utils.getKey(config.title);
  this.parentKey = parentKey || null;
  this.title = utils.titlefy(config.title),
  this.filename = `${utils.getKey(config.title)}.html`,
  this.path = this.parentKey ? `${this.parentKey}/${this.filename}` : this.filename,
  
  this.contentSrc = config.content, // filename or glob pattern
  this.contentCompiled = [], // compiled content
  this.layoutSrc = config.layout ? path.join(this.meta.layouts, config.layout) : path.join(this.meta.layouts, 'default.ejs') , // path to template
  this.compiled = '', // Final compiled page

  this.fileDependencies = [], // array of all file deps
  this.processor = config.processor || null // will content be run through a preprocessor
}

module.exports = Page;