yo-static

1.2.0 • Public • Published

yo-static

stability travis npm version js-standard-style

yo-yo single-page website and isomorphic static site generator

yo-static is a tiny library (11.1kb minified and gzipped) that helps you build a fast, single-page website. It also generates a static version of the site that you can upload to Github Pages or Amazon S3 so you get fast loading pages and search engine SEO without needing to maintain a server. Whatever page you enter the site, from there it acts as a single-page app.

yo-static uses the excellent yo-yo library under the hood, and recommends you do too, but it doesn't really care what you use. Pages and Layouts are just javascript functions that should return a DOM element that will be rendered into document.body.

Content pages are markdown, with YAML Front Matter. Markdown is rendered as html and passed as a parameter to the layout functions.

yo-static is inspired by @shama's website dontkry.com and borrows a lot of ideas from jekyll.

Needs some docs! For now check digidem/digital-democracy.org/tree/yo-yo (also WIP)

Table of Contents

Install

npm i -g yo-static

Usage

Create pages by creating javascript files in a _pages folder. They must export a function that will receive a props argument and must return a DOM element that will be rendered to the page body.

var yo = require('yo-yo')
var layout = require('./default-layout')
 
module.exports = function renderIndex (props) {
  return layout({},
    yo`<div>
      <h1>Welcome to Yo-Static</h1>
      <p>Create an <code>index.js</code> file in <code>${props.site.pages_dir}</code>
      and add some markdown files to <code>${props.site.content_dir}</code> to get started</p>`
  )
}

Create content by creating markdown files in a _content folder. You can define a layout in YAML front matter or a default layout will be used.

Create layouts as javascript files in a _layouts, the content will be available as the second argument:

var yo = require('yo-yo')
 
module.exports = function defaultLayout (props, children) {
  return yo`<body>
    ${children}
  </body>`
}

To serve a site locally for development:

yo-static serve

To build a site for deployment:

yo-static build

Your site will be in _site

Development Status

This is experimental. As we figure out the best API, things might change and things might break (we don't have good test coverage yet, but would welcome contributions).

Contribute

PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Gregor MacLennan

Dependencies (41)

Dev Dependencies (2)

Package Sidebar

Install

npm i yo-static

Weekly Downloads

7

Version

1.2.0

License

MIT

Last publish

Collaborators

  • gmaclennan