Go to Latest
function extract
import { extract } from "https://deno.land/std@0.158.0/encoding/front_matter.ts";

Extracts front matter from a string.

Type Parameters

optional
T = unknown

Parameters

str: string

String to extract from.

import { extract } from "https://deno.land/std@0.158.0/encoding/front_matter.ts";
import { assertEquals } from "https://deno.land/std@0.158.0/testing/asserts.ts";

const { attrs, body, frontMatter } = extract<{ title: string }>("---\ntitle: Three dashes marks the spot\n---\n");
assertEquals(attrs.title, "Three dashes marks the spot");
assertEquals(body, "");
assertEquals(frontMatter, "title: Three dashes marks the spot");