Skip to main content
Module

x/blog/deps.ts>frontMatter

Minimal boilerplate blogging.
Go to Latest
function frontMatter
import { frontMatter } from "https://deno.land/x/blog@0.5.0/deps.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.221.0/encoding/front_matter.ts";
import { assertEquals } from "https://deno.land/std@0.221.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");

Returns

Extract<T>