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
- Host: GitHub
- URL: https://github.com/kodedninja/nanocrane
- Owner: kodedninja
- Created: 2019-08-19T09:33:25.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-24T19:03:31.000Z (almost 7 years ago)
- Last Synced: 2025-02-04T04:54:37.196Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
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
}
```