Class: Middleman::Blog::TagPages
- Inherits:
-
Object
- Object
- Middleman::Blog::TagPages
- 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
-
#initialize(app, blog_controller) ⇒ TagPages
constructor
Initialise Tag pages.
-
#link(tag) ⇒ String
Get a path to the given tag, based on the :taglink setting.
-
#manipulate_resource_list(resources)
Update the main sitemap resource list.
Methods included from UriTemplates
apply_uri_template, date_to_params, extract_directory_path, extract_params, safe_parameterize, uri_template
Constructor Details
#initialize(app, blog_controller) ⇒ TagPages
Initialise Tag pages
20 21 22 23 24 25 26 27 |
# File 'lib/middleman-blog/tag_pages.rb', line 20 def initialize(app, blog_controller) @sitemap = app.sitemap @blog_controller = blog_controller @tag_link_template = uri_template blog_controller..taglink @tag_template = blog_controller..tag_template @blog_data = blog_controller.data @generate_tag_pages = blog_controller..generate_tag_pages end |
Instance Method Details
#link(tag) ⇒ String
Get a path to the given tag, based on the :taglink setting.
35 36 37 |
# File 'lib/middleman-blog/tag_pages.rb', line 35 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
45 46 47 48 49 50 51 |
# File 'lib/middleman-blog/tag_pages.rb', line 45 def manipulate_resource_list(resources) return resources unless @generate_tag_pages resources + @blog_data..map do |tag, articles| tag_page_resource(tag, articles) end end |