extract
import { extract } from "jsr:@ende/front-matter/unstable-yaml";function ยท experimental
function extract<T>(text: string, options?: ParseOptions): Extract<T>Extracts and parses YAML from the metadata of front matter content.
text: stringThe text to extract YAML front matter from.
options?: ParseOptionsThe options to pass to
@ende/yaml/parse.
Returns
The extracted YAML front matter and body content.
Example: Extract YAML front matter
import { extract } from "@ende/front-matter/unstable-yaml";
import { assertEquals } from "@ende/assert";
const output = `---yaml
date: 2022-01-01
---
Hello, world!`;
const result = extract(output, { schema: "json" });
assertEquals(result, {
frontMatter: "date: 2022-01-01",
body: "Hello, world!",
attrs: { date: "2022-01-01" },
});