All files / front_matter / _shared.ts

100.00% Branches 3/3
100.00% Lines 8/8
1
2
3
4
5
6
7
8
9
10
11
 
 
x12
x12
x12
 
x75
x75
x110
x440
x75









// Copyright 2018-2025 the Deno authors. MIT license.

export function extractFrontMatter(
  input: string,
  extractRegExp: RegExp,
): { frontMatter: string; body: string } {
  const groups = extractRegExp.exec(input)?.groups;
  if (!groups) throw new TypeError("Unexpected end of input");
  const { frontMatter = "", body = "" } = groups;
  return { frontMatter, body };
}