@smartfrog/motor
v2.0.6
Published
<p align="center"><img width="auto" src="logo.png"></p>
Downloads
1
Keywords
Readme
MOTOR
MOTOR is a lightweight engine aimed to rapidly build static pages by fetching entries from [contentful CMS API] (https://www.contentful.com/) and injecting their content into [pug] (https://pugjs.org/api/getting-started.html) based layout sections.
Main features:
- minimal setup required
- highly flexible customization fitting any specific project structure
- ultra simple and fast routing configuration
- comprehensive internationalization support
- Contentful Preview API support (previewing unpublished content as though it were published)
- markdown support
Installation
using yarn
yarn add @smartfrog/motor
using npm
npm i -S @smartfrog/motor
Usage
please not that you need node v7.6 or v6 harmony mode to run this project
- create
.env
file from.env.sample
or set needed them env variables from cli before starting motor
NODE_ENV = development
MOTOR_PORT = 4000
SPACE_ID = contentful_SPACE_ID
ACCESS_TOKEN = contentful_ACCESS_TOKEN
- follow
usage.sample.js
and create your entry javascript file that it will reflect the project specs with the right paths.
const motor = require('motor')
const path = require('path')
const config = {
path: {
env: path.resolve(__dirname, '.env'),
views: path.resolve(__dirname, 'views'),
templates: path.resolve(__dirname, 'templates'),
i18n: path.resolve(__dirname, 'i18n')
},
static: [
{
directory: 'static',
path: path.resolve(__dirname, 'static')
}
],
supportedLangs: ['en', 'de']
}
motor(config)
- run your entry file with node, so if the file called
entry.js
use
node entry
use
nodemon
for live-reload
internal project dev
1- install dependencies
$ yarn
or
$ npm i
2- add .env file and entry.js
3- run with live-reload
$ npm run dev
run without live-reload
$ npm start
Docs
generate docs with
$ npm run docs
- project docs available under folder
docs
, you can serve it withhttp-server docs
Debug
you can view API traffic in your browser under debug/console