https://github.com/bernardodiasc/filestojson
Generates JSON from static files [stable]
https://github.com/bernardodiasc/filestojson
cms frontmatter javascript json markdown nodejs static-database static-files
Last synced: 22 days ago
JSON representation
Generates JSON from static files [stable]
- Host: GitHub
- URL: https://github.com/bernardodiasc/filestojson
- Owner: bernardodiasc
- License: mit
- Created: 2017-08-19T16:07:20.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-12T12:54:33.000Z (over 7 years ago)
- Last Synced: 2025-04-02T20:06:01.278Z (about 1 month ago)
- Topics: cms, frontmatter, javascript, json, markdown, nodejs, static-database, static-files
- Language: JavaScript
- Homepage: https://bernardodiasc.github.io/filestojson/
- Size: 248 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# filestojson
This script will generarate JSON file from content files.
## Setup
```shel
npm install filestojson --save-dev
```Note: you may have to install Babel globaly to be able to use this lib:
```shell
npm install -g babel-cli
```## Examples
What's the application of this? You may ask.
Check the examples of different front-end stacks loading the data and rendering the page:
```shell
npm run examples
```## How to use
Command line:
```shell
filestojson ./path/to/config.js
```Script:
```js
import config from './path/to/config.js'
filestojson(config)
```### Configuration
Please refer to the [examples/config.js](examples/config.js) implementation for further example.
Explaining, the `config` is expected to return an object with the keys:
- `content` should be a string for the content folder path, where all content types containing markdown, images and other suff are located;
- `output` should be a string for the JSON file path that will be generated;
- `include` should be an array of strings, where the strings are file extensions that will be included;
- `exclude` should be an array of strings, where the strings are file name with the extension that will be ignored;
- `contentTypes` should be an array of object, each object containing key and the content type translation function;### Content types and translations
... TBP ...