generateItemsTask

Summary

Generates HTML pages for collections of items (e.g., blog posts, portfolio entries) from Markdown or data files. Supports sorting, excerpts, custom templates, and configurable output structure.

Default Behavior

With minimal config, reads all Markdown files in the specified itemsDir, sorts them by date (if available), and renders each to an HTML page using the specified item template. Also generates an index/list page for the collection.

Configuration Options

Example config:

generateItemsTask({
  itemsDir: 'src/posts',
  partialsDir: 'src/partials',
  outDir: 'public/posts',
  outputVar: 'posts',
  templateExtension: '.html',
  partialExtension: '.html',
  flatStructure: false,
})

Input Expectations

Example:

src/
  posts/
    first-post.md
    second-post.md
  templates/
    post.html
    posts.html

Output

Example:

public/
  posts/
    first-post/index.html
    second-post/index.html
    index.html

Practical Example

const { generateItemsTask } = require('skier/builtins');

module.exports = [
  generateItemsTask({
    itemsDir: 'src/posts',
    partialsDir: 'src/partials',
    outDir: 'public/posts',
    outputVar: 'posts',
    templateExtension: '.html',
    partialExtension: '.html',
    flatStructure: false,
  }),
];

Common Pitfalls & Tips

Related Tasks/Docs