docs: function toJSON (file, config) {
    if (Path.extname(file.path) === '.json') {
      if (!isJSON(file)) file.isInvalid = true;
      return Promise.resolve(file);
    }
  
    let jsonFile = file.clone();
  
    return Promise.resolve(file)
      // parse YAML
      .then(file => {
        try {
          let parsed = frontmatter(file.contents.toString());
          return Promise.resolve(parsed);
        } catch (err) {
          return Promise.reject(err);
        }
      // parse and render Markdown
      }).then(parsed => {
        try {
          let data = parsed.attributes;
          data.body = config.renderer.call(config.context, parsed.body);
          return Promise.resolve(data);
        } catch (err) {
          return Promise.reject(err);
        }
      // optional transforms and output
      }).then(data => {
        if (!data.title) {
          let extracted = extractTitle(data.body, config.stripTitle);
          if (typeof extracted === 'object') data = assign(data, extracted);
        }
  
        data.updatedAt = file.stat.mtime.toISOString();
  
        if (config.transform) var transformedData = config.transform(data, file);
  
        jsonFile.extname = '.json';
        jsonFile.contents = new Buffer(JSON.stringify(transformedData || data));
  
        return Promise.resolve(jsonFile);
      });
  }