2.2.4 • Published 4 years ago

frontmeta v2.2.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

FrontMeta is a minimalist front-matter format that uses key:value pairs rather than YAML. This results in a parser that is optimized for both size and speed.

GitHub Releases NPM Release Bundlephobia MIT License Latest Status Release Status

Features

  • ECMAScript Module
  • CommonJS Bundle Included
  • Typescript Compatible

Installation

npm install frontmeta
import frontmeta from 'frontmeta';

Usage

Parse and stringify FrontMeta

FrontMeta.parse()

FrontMeta.parse(frontmeta) : object

  • contents - a string representing the document contents

Example

frontmeta

---
key1:value1
key2:value2
---
This is the document body.
import FrontMeta from '/path/to/frontmeta/index.js';
const frontmeta = // the document frontmeta
const parsed = FrontMeta.parse(frontmeta)
console.log(parsed);
> {
>   "meta": {
>     "key1": "value1",
>     "key2": "value2"
>   },
>   "body": "This is the document body."
> }

FrontMeta.parse()

FrontMeta.stringify(document) : object

  • document - The frontmeta document object
    • meta - the frontmeta key:value data
    • body - the document body

document

{
  "meta": {
    "key1": "value1",
    "key2": "value2"
  },
  "body": "This is the document body."
}
import FrontMeta from '/path/to/frontmeta/index.js';
const document = // the frontmeta document object
const parsed = FrontMeta.stringify(document)
console.log(parsed);
> ---
> key1:value1
> key2:value2
> ---
> This is the document body.

CommonJS

A .cjs bundle is included for CommonJS compatibility

FrontMeta.parse()

const FrontMeta = require('frontmeta');
const frontmeta = // the document frontmeta
const data = FrontMeta.parse(frontmeta);

FrontMeta.stringify()

const FrontMeta = require('frontmeta');
const document = // the frontmeta document object
const data = FrontMeta.stringify(document);

Typings

Typings are generated from JSDoc using Typescript. They are 100% compatible with VSCode Intellisense and will work seamlessly with Typescript.

2.2.4

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.20

4 years ago

2.1.19

4 years ago

2.1.18

4 years ago

2.1.17

4 years ago

2.1.16

4 years ago

2.1.15

4 years ago

2.1.14

4 years ago

2.1.13

4 years ago

2.1.12

4 years ago

2.1.11

4 years ago

2.1.10

4 years ago

2.1.9

4 years ago

2.1.6

4 years ago

2.1.8

4 years ago

2.1.7

4 years ago

2.1.4

4 years ago

2.1.2

4 years ago

2.1.3

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago