Panini 2.0 Preview

Geoff Kimball edited this page Jun 14, 2017 · 1 revision

This is a work in progress.

The second version of Panini will bring it up to punching weight with other static site tools.

Pages

  • Cross-referencing pages: a page has access to a pages variable, which is an array of metadata on all pages in the site. With this, you can dynamically generate navigation.

Data

  • More format support: data files can now be JSON, YAML, CSON, or a .js file with module.exports. A JavaScript file can also be a function that returns data, or an asynchronous function that returns a Promise containing data.
  • Deep merging of page data. when page-specific data is combined with global data, objects are deeply merged.

Localization

  • Translation strings: locale-specific data files containing translation strings can be created. Within pages, the {{translate}} helper allows you to reference a specific string.
  • Automatic page generation: when you create multiple locales for your site, each page will be rendered multiple times and dropped into folders for each locale, i.e. /en/index.html, /is/index.html.
  • Locale-specific pages: a page can be placed into a locale-specific folder, such as /en/about.hbs, and that page will not be translated into other languages.

Collections

Page Transforms

Rendering Engines

  • Pug and EJS support: in addition to the default of Handlebars, the rendering engine can also be switched to Pug or EJS.
  • More built-in helpers: for Pug and EJS, the template-helpers library is built-in. For Handlebars, the more specific handlebars-helpers library is included. This means each engine has access to over a hundred helper functions out of the box.

Configuration

  • No configuration required: the only things you need to run Panini are input and output folders. By default, Panini will look for pages, layouts, partials, etc. in default folder names: pages, layouts, partials, etc.

API

A better programmatic API has been added.

const Panini = require('panini');

const p = new Panini('src', 'dist');

// Build once
await p.build();
console.log('Build done.');

// Build and watch for changes
p.watch();

CLI

The CLI has been simplified. You just specify input and output folders, and optionally a --watch flag.

$ panini src dist

Options can be set with a panini key on your project's package.json.

Breaking Changes

  • Configuration
    • Instead of defining globs of files to pick up (e.g., src/pages/**/*.html, a folder is set instead (e.g., just pages).
    • Folders for specific features (pages, layouts, partials, etc.) must now be immediate subfolders of the root project folder.
    • Removed the ability to specify multiple folders per feature with an array.
  • Handlebars
    • #ifPage and #unlessPage have been replaced by the more generic currentPage, which returns a boolean.
    • #code has been replaced by #highlight in handlebars-helpers.
    • #ifEqual has been replaced by eq in handlebars-helpers.
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.