Class: Middleman::Blog::TagPages

Inherits:
Object
  • Object
show all
Includes:
UriTemplates
Defined in:
lib/middleman-blog/tag_pages.rb

Overview

A sitemap resource manipulator that adds a tag page to the sitemap for each tag in the associated blog

Instance Method Summary collapse

Methods included from UriTemplates

apply_uri_template, date_to_params, safe_parameterize, uri_template

Constructor Details

#initialize(app, blog_controller) ⇒ TagPages

Returns a new instance of TagPages.



10
11
12
13
14
15
16
# File 'lib/middleman-blog/tag_pages.rb', line 10

def initialize(app, blog_controller)
  @sitemap = app.sitemap
  @blog_controller = blog_controller
  @tag_link_template = uri_template blog_controller.options.taglink
  @tag_template = blog_controller.options.tag_template
  @blog_data = blog_controller.data
end

Instance Method Details

Get a path to the given tag, based on the :taglink setting.

Parameters:

  • tag (String)

Returns:

  • (String)


21
22
23
# File 'lib/middleman-blog/tag_pages.rb', line 21

def link(tag)
  apply_uri_template @tag_link_template, tag: safe_parameterize(tag)
end

#manipulate_resource_list(resources)

This method returns an undefined value.

Update the main sitemap resource list



27
28
29
30
31
# File 'lib/middleman-blog/tag_pages.rb', line 27

def manipulate_resource_list(resources)
  resources + @blog_data.tags.map do |tag, articles|
    tag_page_resource(tag, articles)
  end
end