An open API service indexing awesome lists of open source software.

https://github.com/kodedninja/nanocrane

🏗 Versatile static-site builder for Choo
https://github.com/kodedninja/nanocrane

Last synced: 7 months ago
JSON representation

🏗 Versatile static-site builder for Choo

Awesome Lists containing this project

README

          

# nanocrane

Stability


NPM version

Versatile static-site builder library for [Choo](https://github.com/choojs/choo).

Merges an exported Choo application + a state object with content + an HTML string and outputs a set of static HTML files.

## Installation
```
npm i nanocrane
```

## Example

```javascript
var app = require('./index.js')
var nanocrane = require('nanocrane')

var content = {
'/': { title: 'home' },
'/about': { title: 'about' }
}
var template = `





`

nanocrane(app, { content: content }, template)
```

## Usage

### `nanocrane(app, state, htmlString, options)`

`app` is a mounted Choo application, `state` is an object that'll be forwarded to Choo's state, `htmlString` is the template of the outputted HTML files. Returns a `Promise`.

`state.content` must be set and follow [`nanocontent`](https://github.com/jondashkyle/nanocontent)'s basic structure.

In the template it'll replace the following:

- `` ― with the HTML output of the app
- `` ― with a script element that sets the initial state for Choo
- `` ― with the title of the current page

Options:
```
{
clear: bool - whether to clear output path (default: true),
copy: array - paths to copy to output,
output: string,
outputRoute: function - called on every route with `(route, html, options)` (default: write to output directory),
verbose: bool
}
```