The Tagger extension allows organizing site content based upon tags meta-data in paginated collections.

Usage

Given the configuration of:

  extension Awestruct::Extensions::Tagger.new( :posts, 
                                               '/index', 
                                               '/blog/tags', 
                                               :per_page=>10 )

The extension will scan site.posts for every item with a tags attribute. For each observed tag, a structure is created with the following behaviour

These structures will be sorted by popularity, trimmed to the top 100 tags, and placed into site.posts_tags as an ordered array. This array

Method Description
to_s The seen tag
primary_page First page in this tag's index collection
pages All pages with the tag
group Which group is this tag in terms of popularity

From this analysis, the extension will create a paginated index for each of the top 100 tags. The input_path page denotes which page should be used to iterate the tag's page collection.

The page.posts collection, in this case, will hold the page's worth of posts with a given tag.

The indexes will be output under the output_prefix directory.

The pages listing all posts of 1 specific tag (so filtering out other posts), have a page.selected_tag variable with the name of the tag, which is usefull to adjust the page title accordingly.

To draw a full tag-cloud, the TagCloud extension should be used.

Parameters

Awestruct::Extensions::Tagger.new(collection_name, input_path, output_prefix, opts)

Parameter Description
collection_name The name of the property on `site` to act as a source of tagged pages, typically an array.
input_path Path to page to enumerate tagged items.
output_prefix Path prefix to emit the resulting tagged pages
opts Additional options hash (see below). Also passed to an internal `Paginator`

Options

per_page Number of items per page.
sanitize Whether or not tag urls are lower cased and whitespaces replaced with dash for nicer URLs (default to false).
window_size The number of pages on either side of the first, last or around the current page when drawing links.

Examples

Generic Installation

Awestruct::Extensions::Pipeline.new do
  extension Awestruct::Extensions::Tagger.new(collection_name, input_path, output_prefix, opts)
end

Typical usage to tag blog posts, 10-per-page

Awestruct::Extensions::Pipeline.new do
  extension Awestruct::Extensions::Tagger.new( :posts, 
                                               '/index', 
                                               '/blog/tags', 
                                               :per_page=>10 )
end

See Also