Class: Mill::Resource::Sitemap

Inherits:
Mill::Resource show all
Defined in:
lib/mill/resources/sitemap.rb

Constant Summary

Constants inherited from Mill::Resource

FileTypes

Instance Attribute Summary

Attributes inherited from Mill::Resource

#content, #date, #input_file, #node, #output_file, #path, #public, #site

Instance Method Summary collapse

Methods inherited from Mill::Resource

#absolute_uri, #change_frequency, #children, #final_content, #initialize, #inspect, #load, #parent, #public?, #redirect?, #save, #siblings, #tag_uri, #text?, #uri

Constructor Details

This class inherits a constructor from Mill::Resource

Instance Method Details

#buildObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mill/resources/sitemap.rb', line 9

def build
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.urlset('xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
               'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
               'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd') do
      @site.public_resources.each do |resource|
        xml.url do
          xml.loc(resource.absolute_uri)
          xml.lastmod(resource.date.iso8601)
          xml.changefreq(resource.change_frequency.to_s)
        end
      end
    end
  end
  @content = builder.doc
  super
end