npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

markdown-posts-to-json

v0.0.10

Published

将 Markdown 格式的文章(.md)后缀,提取元数据,并使用 Markdown-it 将文章内容转化为 Html,最后输出为 json 文件。

Readme

Markdown posts to JSON

本插件主要功能是将 Markdown 文档头部的 YAML 格式数据进行提取,其余部分作为文章内容转化为 HTML 格式,并将上述内容转换为 JSON 格式输出。

主要是为了满足对博客文章的处理需求。

同时会生成一个索引文件(JSON),内容为一个包含所有文章元数据(文章头部 YAML 格式部分)内容的对象。对象结构与目录结构相同,并支持将 index.md 文件的元数据合并至它所在目录的对象中

使用方法:

本插件需配合 Webpack 服用,只需在 Webpack 配置文件中如下配置即可,对于 Markdown-It 的配置,可在 md 属性中进行配置,md 属性必须存在,最简设置为:new MarkdownIt()。其他选项均非必须(但估计你不会喜欢我的默认值)。

如果需要代码高亮(按如下配置即可实现),需在页面中自行引入 highlight.js 的样式表,例如:import 'highlight.js/styles/atom-one-dark.css'

Webpack 配置

  const hljs = require("highlight.js")
  const MarkdownIt = require("markdown-it")

  ...

    plugins: [
    // Markdown posts 2 json data
    new mp2j({
      // input path, your posts path
      postPath: path.resolve(__dirname, './posts'),
      // output path
      outPath: 'dist/posts',
      // include sub dir
      includeSubPath: true,
      // name for index of JSON
      indexName: 'index',
      // merge index.md's metadatas to its dir
      mergeIndex2dir: true,
      // default Node's name
      defaultNode: 'default',
      // sub Node's name
      subNode: 'posts',
      // all prefix is 'mi_' keys will be remove prefix and transfered to Markdown-it. This is default option of Markdown-It
      md: new MarkdownIt({
        html: false,
        xhtmlOut: false,
        breaks: false,
        langPrefix: 'language-',
        linkify: false,
        typographer: false,
        quotes: '“”‘’',
        highlight: function (str, lang) {
          if (lang && hljs.getLanguage(lang)) {
            try {
              return '<pre class="hljs"><code>' +
                    hljs.highlight(lang, str, true).value +
                    '</code></pre>';
            } catch (__) {}
          }
          return '<pre class="hljs"><code>' + mp2j.options.md.utils.escapeHtml(str) + '</code></pre>';
        }
      })
    })
  ]

更新日志:

0.0.10

增加默认根节点名称的设置

0.0.9

支持使用 parent 设置父节点,支持多个根节点。

0.0.8

修改依赖引入位置,以及 Markdwon-It 选项传入方式,现在可正常实现代码高亮(需自行引入 highlight.js 的样式表)

0.0.7

文章数据分割正则优化

0.0.6

修正索引文件层级问题,可以设置索引文件中子节点的名称

0.0.5

分割正则优化

0.0.4

包信息完善

0.0.3

优化索引文件结构

0.0.2

实现了 Markdown-it 的参数传入

0.0.1

功能初步实现