Skip to main content
Module

std/front_matter/json.ts>extract

The Deno Standard Library
Latest
variable extract
import { extract } from "https://deno.land/std@0.222.1/front_matter/json.ts";

Extracts and parses JSON from the metadata of front matter content.

Examples

Example 1

import { extract } from "https://deno.land/std@0.222.1/front_matter/json.ts";

const output = `---json
{
  "title": "Three dashes marks the spot"
}
---
Hello, world!`;
const result = extract(output);

result.frontMatter; // '{\n "title": "Three dashes marks the spot"\n}'
result.body; // "Hello, world!"
result.attrs; // { title: "Three dashes marks the spot" }