function extractor(string) {
  string = string || '';

  const lines = string.split(/(\r?\n)/);
  if (lines[0] && /= yaml =|---/.test(lines[0])) {
    return parse(string);
  } else {
    return { attributes: {}, body: string };
  }
}
Fork https://github.com/egoist/docute/blob/master/src/utils/front-matter.js