Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.9 KB

README.MD

File metadata and controls

43 lines (29 loc) · 1.9 KB

npm version Build Status codecov

hexo-front-matter-editor

A simple library to read / write / create markdown files of hexo blog posts.

APIs

Editor.read(String from)

Read your hexo markdown file and parse it to an FrontMatterData object.

  • from / the path of your post markdown file.

returns Promise<FrontMatterData result>

Editor.create(Object initObj)

Create an FrontMatterData object.

returns FrontMatterData result;

Editor.write(FrontMatterData data, Object to)

  • initObj / a FrontMatterData object
  • to / the output markdown file path.

FrontMatterData APIs

It just a simple key-value pair handler.

FrontMatterData.add(String key, String | Date | Array | null | undefined value)

Add a key-value pair;

FrontMatterData.remove(String key, String | Date | Array | null | undefined value)

Remove key-value pair;

FrontMatterData.set(String key, String | Date | Array | null | undefined value)

Set an exist key with a new value. If key doesn't exist in object, it will add a new key-value pair instead.

Notice

All methods in FrontMatterData, you always should not to use Object (Date/Array/null are not included) as your value input. When you use Editor.write() to output your FrontMatterData to a markdown file(s), that Object value will be transformed to "[Object Object]". This is the default behavior of hexo-front-matter.