Class: Middleman::Blog::TagPages
- Inherits:
-
Object
- Object
- Middleman::Blog::TagPages
- Defined in:
- lib/middleman-blog/tag_pages.rb
Overview
A sitemap plugin that adds tag pages to the sitemap based on the tags of blog articles.
Class Method Summary collapse
-
.link(blog_options, tag) ⇒ String
Get a path to the given tag, based on the :taglink setting.
Instance Method Summary collapse
- #blog_data ⇒ Object
- #blog_options ⇒ Object
-
#initialize(app, controller = nil) ⇒ TagPages
constructor
A new instance of TagPages.
-
#manipulate_resource_list(resources)
Update the main sitemap resource list.
Constructor Details
#initialize(app, controller = nil) ⇒ TagPages
Returns a new instance of TagPages.
17 18 19 20 |
# File 'lib/middleman-blog/tag_pages.rb', line 17 def initialize(app, controller=nil) @app = app @blog_controller = controller end |
Class Method Details
.link(blog_options, tag) ⇒ String
Get a path to the given tag, based on the :taglink setting.
12 13 14 |
# File 'lib/middleman-blog/tag_pages.rb', line 12 def link(, tag) ::Middleman::Util.normalize_path(.taglink.sub(':tag', tag.parameterize)) end |
Instance Method Details
#blog_data ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/middleman-blog/tag_pages.rb', line 22 def blog_data if @blog_controller @blog_controller.data else @app.blog end end |
#blog_options ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/middleman-blog/tag_pages.rb', line 30 def if @blog_controller @blog_controller. else @app.blog. end end |
#manipulate_resource_list(resources)
This method returns an undefined value.
Update the main sitemap resource list
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/middleman-blog/tag_pages.rb', line 40 def manipulate_resource_list(resources) resources + self.blog_data..map do |tag, articles| path = TagPages.link(self., tag) p = ::Middleman::Sitemap::Resource.new( @app.sitemap, path ) p.proxy_to(self..tag_template) # Add metadata in local variables so it's accessible to # later extensions p. :locals => { 'page_type' => 'tag', 'tagname' => tag, 'articles' => articles, 'blog_controller' => @blog_controller } # Add metadata in instance variables for backwards compatibility p. do @tag = tag @articles = articles end p end end |