jellekralt / markdown-folder-api

Markdown Folder API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Markdown Folder API

Takes a folder path as an imput, and parses the markdown files inside. The parsed files are stored and can be retreived with an API.

Install

# NPM
npm i markdown-folder-api 

# Yarn
yarn add markdown-folder-api

Usage

let mdFiles = new MarkdownFolder({
  path: '/folder/path'
});

mdFiles.on('load', () => {
  // Get all files
  let allFiles = mdFiles.getAll();
  // Get single file
  let someFile = mdFile.get('fileName');
  // Get single file in a subfolder
  let anotherFile = mdFile.get('folderName/fileName');
});

File structure

{
  "data": "...", // Raw file data
  "filePath": "...", // Absolute file path
  "attributes": {
    ... // All attributes from the front matter
  },
  "body": "...", // Body of the file, without the front matter
  "frontmatter": "...", // Raw front matter
  "html": "..." // Generated HTML
}

Options

new MarkdownFolder({
  // Absolute folder path (String)
  path: '/folder/path'
  // Switch to enable / disable slugifying the folder / filename (Boolean) 
  // Default: false
  slugify: true
});

Disclaimer

This software is currently BETA quality, use at your own risk

About

Markdown Folder API


Languages

Language:JavaScript 100.0%