Home

Awesome

Lego

Build Status

A fast Static Site Generator that generates optimised, performant websites.

Screenshot

Tell me more

Installation

Usage

::: lego-image src="static/images/${IMAGE}" res="1080,500,320" alt="alternate text" class="img-responsive center-block" :::
{% unless isDevelopment %}
  <!-- analytics code -->
{% endunless %}

Directory structure

.
├── CNAME
├── README.md
├── layouts
│   ├── post.html             // will be used for markdown posts
│   └── tags.html             // will be used to generate tag wise listing of posts
├── pages
│   ├── 404.html
│   └── about.html            // each of these will be put under a separate folder in build
│   └── index.html
├── data
│   ├── authors.yml
│   └── speakers.yaml         // will be available as data.authors and data.speakers
├── posts
│   ├── post.md
│   └── another-post.md
└── static
    ├── css
    │   └── styles.css        // possible to have sub folders
    ├── images
    └── js
        └── custom-scripts.js

Configuration file

Every lego project has a lego.js file at the root. It should have the following contents:

critical: {
  inline: true,
  dimensions: [
    {
      height: 800,
      width: 470
    }, {
      height: 900,
      width: 1200
    }
  ],
  penthouse: {
    timeout: 150000
  }
}
.
└── posts
    ├── travel
    │   └── nepal.md
    └── i-love-js.md

the URL of nepal.md will be site.com/nepal if this option is true. By default(false), the URL of this post would be site.com/travel/nepal. This option will be overridden if the post's front-matter has a url field.

ssl: {
  key: 'server.key',
  cert: 'server.crt'
}
{
  collapseWhitespace: true,
  minifyJS: true,
  minifyCSS: true,
  removeComments: true
}
const emoji = require('markdown-it-emoji');
const toc = require('markdown-it-table-of-contents');

{
  md: {
    containers: [
      {
        name: 'myCustomContainer',
        options: {
          validate: function(params) {}
          render: function(tokens, idx) {}
        }
      }
    ],
    plugins: [
      emoji,
      [
        toc, {
          containerClass: 'toc',
        }
      ]
    ]
  }
}
{
  postCSSPlugins: [
    'precss',
    'postcss-nested'
  ]
}

Benchmarks

To run benchmarks, run

$ cd benchmarks
$ yarn
$ node generator.js
$ node --max-old-space-size=4096 index.js

It will run benchmarks against jekyll the following data:

While jekyll produces only a build, lego does HTML minification as well.

Results:

jekyll x 0.04 ops/sec ±3.48% (5 runs sampled)
lego without cache x 0.24 ops/sec ±11.03% (5 runs sampled)
lego with cache x 0.35 ops/sec ±2.36% (5 runs sampled)
Fastest is lego with cache

License

MIT © Sivasubramanyam A