https://github.com/bitkris-dev/strapi-to-static
Fetch your strapi endpoints and save them as static JSON files
https://github.com/bitkris-dev/strapi-to-static
endpoints json rest rest-api restful-api static static-site-generator strapi
Last synced: 2 months ago
JSON representation
Fetch your strapi endpoints and save them as static JSON files
- Host: GitHub
- URL: https://github.com/bitkris-dev/strapi-to-static
- Owner: bitkris-dev
- Created: 2019-07-22T23:21:42.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-03-30T21:09:11.000Z (about 5 years ago)
- Last Synced: 2025-03-04T09:28:28.144Z (over 1 year ago)
- Topics: endpoints, json, rest, rest-api, restful-api, static, static-site-generator, strapi
- Language: JavaScript
- Homepage:
- Size: 232 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Strapi to static
You can use this little global node utility to fetch your strapi endpoints and save them as static JSON files in a dir of your choice.
The idea behind it has born while needing to embed server contents in a static-generated website. You can then make them dynamic-like triggering strapi-to-static and a re-build.
It's extremely simple and easy to use.
Install globally:
```
npm install -g strapi-to-static
```
Accepted CLI arguments:
| name | type | description |
| ------------ | ------ | ---------------------------------------------------- |
| contentTypes | array | content types slugs to fetch from your strapi server |
| dir | string | define your JSON files output directory |
| apiURL | string | the URL in which your strapi server runs |
Example of usage:
```
strapi-to-static --contentTypes=['news'] --dir=src/data --apiURL=http://localhost:1337
```
Then you will have your endpoints exported as single JSON files in the chosen directory.
The best thing is to associate it with a custom "scripts" command in a project's **package.json**, so the output dir is relative to it.
Example:
```
{
"scripts": {
"fetch": "strapi-to-static --contentTypes=['news'] --dir=src/data --apiURL=http://localhost:1337",
},
}
```