JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 99
  • Score
    100M100P100Q56895F
  • License Apache-2.0

A pure ES module runs on Node.js and focus on blog posts batched processing.

Package Exports

  • oaks-post
  • oaks-post/index.mjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (oaks-post) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

简介

这是一个专注于博客项目文章批处理的纯 ES 模块(也就是.mjs)。

功能

  • 解析 Markdown 文件的 Front Matter 和内容两部分,然后把它们提取到一个同名 json 文件中;
  • 计算 Markdown 内容部分的 Hash 值,并写入 Front Matter;

安装

npm install oaks-post

使用

调用如下:

import { processMarkdownFiles } from "oaks-post";
import { join } from "path";

const prefix = process.cwd();

const input = join(prefix, "your markdown directory");
const output = join(prefix, "your json directory");

processMarkdownFiles(input, output);

举个例子,如下 markdown 文件:

---
title: Hello world
contentHash: da3ab45e
---

hello world

所生成的对应 json 文件如下:

{
  "frontMatter": {
    "title": "Hello world",
    "contentHash": "da3ab45e"
  },
  "content": "hello world"
}