UNPKG

@push.rocks/smartfm

Version:

A Node.js module for handling and processing frontmatter in markdown and text files, leveraging the gray-matter library for parsing and stringifying YAML or JSON formatted frontmatter.

25 lines (24 loc) 729 B
import grayMatter from 'gray-matter'; export type TFrontMatter = 'yaml' | 'json'; export interface ISmartfmContructorOptions { fmType: TFrontMatter; } /** * class smartfm handles frontmatter */ export declare class Smartfm { fmType: TFrontMatter; constructor(optionsArg: ISmartfmContructorOptions); /** * add frontmatter to a string */ stringify(bodyString: string, frontmatterData: any): string; /** * parse a string that has frontmatter attached, YAML notation */ parse(stringToParse: string): grayMatter.GrayMatterFile<string>; /** * parse from comments */ parseFromComments(commentStart: string, stringToParse: string): grayMatter.GrayMatterFile<string>; }