Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/klaytonfaria/markdown-json
Markdown to json has yaml support and converts your markdown files to json so you can use them as a static api.
https://github.com/klaytonfaria/markdown-json
api json markdown static yaml
Last synced: about 20 hours ago
JSON representation
Markdown to json has yaml support and converts your markdown files to json so you can use them as a static api.
- Host: GitHub
- URL: https://github.com/klaytonfaria/markdown-json
- Owner: klaytonfaria
- License: mit
- Created: 2017-01-09T15:50:28.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2023-07-11T04:03:40.000Z (over 1 year ago)
- Last Synced: 2025-01-16T07:12:41.595Z (8 days ago)
- Topics: api, json, markdown, static, yaml
- Language: JavaScript
- Homepage:
- Size: 1 MB
- Stars: 100
- Watchers: 5
- Forks: 18
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
markdown-json [![npm](https://img.shields.io/npm/dt/markdown-json.svg)]() [![Standard - JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) ![Publish packages](https://github.com/klaytonfaria/markdown-json/workflows/Publish%20packages/badge.svg)
===Markdown to json has yaml support and converts your markdown files to json so you can use them as a static api.
## Installation
```
npm install markdown-json
```### Command line usage:
```
markdown-json [OPTIONS] [ARGS]Options:
-c, --config [STRING] settings file (Default is ./settings.json)
-D, --display BOOLEAN enable display mode
-d, --dist [STRING] output file directory (Default is ./dist/output.json)
-i, --ignore STRING ignore file pattern
-o, --deterministicOrder BOOLEAN enable deterministic output ordering
-p, --filePattern [STRING] file(s) directory (Default is **/*.md)
-P, --port [NUMBER] server port (Default is 3001)
-S, --server BOOLEAN enable server
-s, --src [STRING] file(s) directory (Default is ./)
-w, --cwd [STRING] work directory (Default is ./)
-h, --help display help and usage details
```### Require module usage:
```JavaScript
const markdownJson = require('markdown-json');markdownJson() // => returns a Promise
```## Usage Example:
---#### Settings example
*Use a object with all settings or save as a json file*```json
{
"name": "markdown-json",
"cwd": "./",
"src": "example/content/",
"filePattern": "**/*.md",
"ignore": "*(icon|input)*",
"dist": "example/output.json",
"metadata": true,
"server": true,
"port": 3001,
"deterministicOrder": false
}
```#### Call through command line example:
```
markdown-json -c ~/app/my-app-settings.json
```#### Call through require module example:
```JavaScript
const markdownJson = require('markdown-json');
const settings = {
name: 'markdown-json',
cwd: './',
src: 'example/content/',
filePattern: '**/*.md',
ignore: "*(icon|input)*",
dist: 'example/output.json',
metadata: true,
server: false,
port: 3001,
deterministicOrder: false
};markdownJson(settings).then((data) => {
console.log('data:', data);
}).catch((err) => {
console.log('error:', err);
})
```## Files input
#### File example 1
```markdown
---
section: Elements
title: icons
tags:
- icons
- base
---# Icons
Our icons list still is empty :(
```#### File example 2
```markdown
---
section: Elements
title: buttons
device:
- desktop
- mobile
styles:
- https://lalao.com/styles/structure.min.css
- https://lalao.com/styles/app.min.css
---Follow some application examples of buttons
Types
============## Base
Base button layout sample:
Button\~~~scss
.btn-primary {
@include states(#1A75CE, #086B9C);
}
\~~~\~~~html
Button\~~~
```## Output:
```json
{
"app": {
"config": "./settings.json",
"cwd": "./",
"src": "example/content/",
"filePattern": "**/*.md",
"dist": "example/output.json",
"name": "markdown-json",
"version": "0.0.1"
},
"data": [
{
"section": "Elements",
"title": "buttons",
"device": [
"desktop",
"mobile"
],
"styles": [
"https://lalao.com/styles/structure.min.css",
"https://lalao.com/styles/app.min.css"
],
"contents": "Follow some application examples of buttons
\nTypes
\nBase
\nBase button layout sample:
\n\n \n Button\n\n\n\n.btn-primary {\n @include states(#1A75CE, #086B9C);\n}\n
\n",<button type="button" class="buy-button btn btn-success">\n <span class="icon"></span>\n <span class="text">Button</span>\n</button>\n
"excerpt": "Follow some application examples of buttons
",
"id": "buttons",
"meta": {
"relativePath": "content/buttons.html",
"createdAt": "2020-10-08T16:05:30.415Z",
"lastModified": "2020-10-08T16:05:14.452Z",
"size": 2095,
"formattedSize": "2.0 KB"
}
},
{
"section": "Elements",
"title": "icons",
"tags": [
"icons",
"base"
],
"contents": "Icons
\nOur icons list still is empty :(
\n",
"excerpt": "Our icons list still is empty :(
",
"id": "icons",
"meta": {
"relativePath": "content/globals/js-utils.html",
"createdAt": "2019-08-27T18:01:33.747Z",
"lastModified": "2019-08-27T18:01:33.747Z",
"size": 331,
"formattedSize": "331 Bytes"
}
}
]
}
```## TODOS
- [X] Node api with promises
- [ ] Unit tests
- [X] Run with http server
- [X] Add file metadata