@smartfrog/motor
v2.0.6
Published
<p align="center"><img width="auto" src="logo.png"></p>
Downloads
12
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/motorusing npm
npm i -S @smartfrog/motorUsage
please not that you need node v7.6 or v6 harmony mode to run this project
- create
.envfile from.env.sampleor 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.jsand 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.jsuse
node entry
use
nodemonfor live-reload
internal project dev
1- install dependencies
$ yarnor
$ npm i2- add .env file and entry.js
3- run with live-reload
$ npm run devrun without live-reload
$ npm startDocs
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
