Skip to main content
Module

x/lume/deps/front_matter.ts>test

🔥 Static site generator for Deno 🦕
Very Popular
Go to Latest
function test
import { test } from "https://deno.land/x/lume@v2.1.3/deps/front_matter.ts";

Tests if a string has valid front matter. Supports YAML, TOML and JSON.

Parameters

str: string

String to test.

optional
formats: Format[]

A list of formats to test for. Defaults to all supported formats.

import { test } from "https://deno.land/std@0.224.0/front_matter/test.ts";

test("---\ntitle: Three dashes marks the spot\n---\n"); // true
test("---toml\ntitle = 'Three dashes followed by format marks the spot'\n---\n"); // true
test("---json\n{\"title\": \"Three dashes followed by format marks the spot\"}\n---\n"); // true
test("---json\n{\"title\": \"Three dashes followed by format marks the spot\"}\n---\n", ["yaml"]); // false

Returns

boolean