0.5.0 • Published 11 months ago

@burmajs/frontmatter v0.5.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
11 months ago

Extract YAML data from a markdown file

API Docs : jsDocs.io

Install

npm

npm i @burmajs/frontmatter

pnpm

pnpm i @burmajs/frontmatter

deno

deno add @burmajs/frontmatter

Usage

example.md

---
type: "post"
title: "Hello World"
---

## Hello

NODE-JS

index.ts

import Frontmatter from "@burmajs/frontmatter";
import fs from "node:fs";
type MyType = {
  type: string;
  title: string;
};
const mdcontent = fs.readFileSync("example.md", "utf-8");
const foo = new Frontmatter<MyType>(mdcontent);

console.log(foo.json); // { data: { type: 'post', title: 'Hello World' }, content: '\n\n## Hello\n'}
console.log(foo.data); // { type: 'post', title: 'Hello World' }
console.log(foo.content); // ## Hello

DENO

mod.ts

import { FrontMatter } from "@burmajs/frontmatter";

type MyType = {
  type: string;
  title: string;
};

const mdcontent = Deno.readTextFileSync("example.md");
const foo = new Frontmatter<MyType>(mdcontent);

console.log(foo.json); // { data: { type: 'post', title: 'Hello World' }, content: '\n\n## Hello\n'}
console.log(foo.data); // { type: 'post', title: 'Hello World' }
console.log(foo.content); // ## Hello
0.5.0

11 months ago

0.4.0

11 months ago

0.3.0

11 months ago

0.1.1

11 months ago