taika.ext.collections – Grouping content

This extension groups documents using patterns specified by the user. It also order those documents using certain keys specified by the user.

It uses the patterns listed from top to bottom, the documents not included in the first pattern are not matched against the second pattern, so be liberal in the first pattern and more restricted at the bottom. Also, if the pattern starts with ! (exclamation mark) the documents matching will be excluded. For example:

collections:
posts:
  patterns:
    - "posts/*" # Include all under posts
    - "!posts/index.rst" # Ignore posts/index.rst

Event

This extension is subscribed to the site-post-read event.

Process

  1. Setup where the collections keys is retrieved.
  2. When the extension is called, scans the documents checking their path.
  3. If path matches the patterns provided, it’s added to the collection.
  4. Finally, the attribute collections is created on taika.Taika.

Configuration

# Match all but the index.rst file on posts/
collections:
  posts:
    patterns:
      - "posts/*" # Include all under posts
      - "!posts/index.rst" # Ignore posts/index.rst
collections(dict)

Default: {}

A dictionary where each key specifies the name of the collection.

collection.patterns(list)

Default: [‘’] (empty string)

The patterns to be used in order to group the files. By default, it matches nothing.

Classes and Functions

class Collector(config)[source]

Main class which retrieves the configuration and the organize the documents.

organize(self, site)[source]

Classify the documents and creates the collections attribute on site.

match(path, patterns, reverse_character='!')[source]
setup(site)[source]