https://github.com/marcomontalbano/netlify-cms-json-exporter
Export all your Netlify CMS contents in a single object with all relations resolved.
https://github.com/marcomontalbano/netlify-cms-json-exporter
c8 cms export json netlify netlify-cms typescript uvu
Last synced: about 2 months ago
JSON representation
Export all your Netlify CMS contents in a single object with all relations resolved.
- Host: GitHub
- URL: https://github.com/marcomontalbano/netlify-cms-json-exporter
- Owner: marcomontalbano
- License: mit
- Created: 2021-02-03T07:21:14.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-02-02T08:01:28.000Z (over 4 years ago)
- Last Synced: 2025-10-27T16:36:36.982Z (8 months ago)
- Topics: c8, cms, export, json, netlify, netlify-cms, typescript, uvu
- Language: TypeScript
- Homepage:
- Size: 155 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Netlify CMS - JSON Exporter
[Netlify CMS](https://www.netlifycms.org/) stores the content in separate folders and files.
With `JSON Exporter` you can export all your Netlify CMS contents in a single object with all relations resolved.
This can be useful if need to inject your content as `props` inside your components.
## Usage
```sh
# with yarn
yarn add -D netlify-cms-json-exporter
# with npm
npm install --save-dev netlify-cms-json-exporter
```
### Export as `db.json`
```js
import fs from 'fs'
import { getContent } from 'netlify-cms-json-exporter'
const content = getContent('./public/admin/config.yml', './content')
fs.writeFileSync('db.json', JSON.stringify(content, undefined, 2))
```
### Typescript `.d.ts`
```js
// netlify-cms-exporter.js
import { getContent } from 'netlify-cms-json-exporter'
const content = getContent('./public/admin/config.yml', './content')
console.log(
JSON.stringify(content, undefined, 2)
)
```
```sh
node netlify-cms-exporter.js | npx json-ts --stdin --prefix "" --rootName Content > db.d.ts
```