Skip to main content
Go to Latest
function extract
import { extract } from "";

Extracts front matter from a string.

Type Parameters

T = unknown


str: string

String to extract from.

import { extract } from "";
import { assertEquals } from "";

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");