0.0.4 • Published 5 years ago
markdown-post-parser v0.0.4
markdown-post-parser
Parser for building blogs in Markdown.
Install
npm install --save-dev markdown-post-parser
Use
CLI
# generate
mpp -m index.md -i ./src -o ./json/blog.json -s ./static
# watch
mpp -w -m index.md -i ./src -o ./json/blog.json -s ./static
API
const MarkdownPostParser = require('markdown-post-parser')
const markdownPostParser = new MarkdownPostParser({
main: 'index.md',
input: './src',
output: './json/blog.json',
static: './static'
})
// generate
markdownPostParser.generate().then(() => {
console.log('Generate completeed')
})
// watch
markdownPostParser.watch()
Example
Directory
src
├─ post-01
│ ├─ index.md
│ └─ example.png
├─ post-02
│ ├─index.md
│ └─ example.png
└─ post-02
└─index.md
Markdown format
src/post-01/index.md
---
id: post-01
title: Example Post
description: test post
created_at: "2019-04-01"
updated_at: "2019-04-01"
tags:
- HTML
- CSS
- JavaScript
---
## overview
text text
- list item
- list item
- list item
- list item
JSON format
{
// All posts
"posts": [
{
"path": "src/post-01",
"main": "src/post-01/index.md",
"id": "post-01",
"title": "Example Post",
"description": "test post",
"created_at": "2019-04-01",
"updated_at": "2019-04-01",
"tags": [
"HTML",
"CSS",
"JavaScript"
],
"body": {
"md": "...", // Markdown source
"html": "...", // HTML source
"text": "..." // Plane text source
},
"resource": [
"src/post-01/example.png"
]
},
...
],
// All tags
"tags": [
"HTML",
"CSS",
"JavaScript",
...
],
// All resources
"resources": [
"src/post-01/example.png",
"src/post-02/example.png"
]
Development
# Build TypeScript
yarn build
# Development mode
yarn dev
# Unit test
yarn test
Todos
- Enhance test code
- Update document
- CLI design