Publican v0.11.0 update

By Craig Buckler

470 words, 3-minute read

root
Image courtesy of Maksym Kaharlytskyi

Publican v0.11.0 was released on .

There should be no breaking changes unless you’ve used a custom groups: value in front matter. This is now a Publican value that controls post groups.

Post groups #

You can organise pages into arbitrary groups based on any factor, e.g. featured posts, years, authors, etc. You can add any post to a group by:

  1. setting a groups: front matter value, e.g. groups: featured, or

  2. defining a filter function in your Publican configuration file.

The following example creates a latest group with all posts dated within the past 28 days in reverse chronological order:

publican.config.js excerpt

publican.config.groupPages = {
  sortBy: 'date',
  sortOrder: -1,
  list: {
    'latest': {
      filter: data => data.date >= new Date(Date.now() - 28 * 24 * 60 * 60 * 1000)
    }
  }
};

You can list grouped posts in any template:

${ tacs.group.get('latest').map(
  p => `<p><a href="${ p.link }">${ p.title }</a></p>`
) }

You can also generate paged index pages by adding a root path and optional size, template, and index values:

publican.config.js excerpt

publican.config.groupPages = {
  sortBy: 'date',
  sortOrder: -1,
  size: 12,
  template: 'list.html',
  index: 'monthly',
  list: {
    'latest': {
      filter: data => data.date >= new Date(Date.now() - 28 * 24 * 60 * 60 * 1000),
      root: 'latest'
    }
  }
};

If there were 30 latest posts, an index size of 12 creates:

For more information, refer to Publican group indexes.

Minor fixes #

Version 0.11.0 fixes the following issues:

  1. Watch mode works on Windows

    Previous versions would not re-render in native Windows installations (not in WSL).

  2. Disable navigation menus

    Set publican.config.nav = false if you’re not using the tacs.nav object. This should make rendering a little faster.

  3. No need for empty content or template directories

    Previous versions required empty directories even when using virtual files alone.

  4. Improved error reporting.

Get started #

The Publican documentation provides a quick start guide, a detailed set-up guide, API references, and common recipes you can use and adapt for your own projects.