Socket
Socket
Sign inDemoInstall

md-to-json-converter

Package Overview
Dependencies
19
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    md-to-json-converter

Converts your markdown files to a single json file so that you can use it as a static api.


Version published
Maintainers
1
Created

Readme

Source

md-to-json-converter

Turn your markdown files into a single JSON file.

Installation

$ npm i md-to-json-converter

or if you use yarn

$ yarn add md-to-json-converter

Usage

The code below displays a simple usecase of this module.

import { converteMdToJSON } from 'md-to-json-converter'
import path from 'path' // not required

const __dirname = path.resolve();
// Path to the director where your markdown files live.
const contentPath = path.join(__dirname, './example/content')
// The path to the JSON file you want to export the result to.
const outputPath = path.join(__dirname, './example/output/posts.json')

// Returns Promise.
converteMdToJSON({
  // available options are listed below.
  contentPath,
  outputPath,
}).then((data) => {
  console.log('data:', data);
}).catch((err) => {
  console.log('error:', err);
})

Here are the options you can set.

NameTypeDescription
contentPathstringRequired The path to the director where your markdown files live.
outputPathstringRequired The path to the JSON file you want to export the result to.
remarkableOptionsRemarkable.OptionsThis module uses remarkable as its markdown parser. You can see here for available options for remarkable
rawbooleanIf this is set to true, the module is not gonna parse the markdonw internally and export the markdown text itself.

Examples

Input

---
title: Test Title
date: 2022-03-05
description: Description for this blog post
tags: [test-tag]
---

## Heading2


Here's an [**important** anchor link](#example).

Two newlines creates a line break.

Output

{
  "data": [
    {
      "body": "<h2>Heading2</h2>\n<p>Here's an <a href=\"#example\"><strong>important</strong> anchor link</a>.</p>\n<p>Two newlines creates a line break.</p>\n",
      "title": "Test Title",
      "date": "2022-03-05T00:00:00.000Z",
      "description": "Description for this blog post",
      "tags": [
        "test-tag"
      ]
    }
  ]
}

Keywords

FAQs

Last updated on 09 Mar 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc