def xml_sitemap(params={})
require 'builder'
items = params[:items] || @items.reject { |i| i[:is_hidden] }
buffer = ''
xml = Builder::XmlMarkup.new(:target => buffer, :indent => 2)
if @site.config[:base_url].nil?
raise RuntimeError.new("The Nanoc::Helpers::XMLSitemap helper requires the site configuration to specify the base URL for the site.")
end
xml.instruct!
xml.urlset(:xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9') do
items.each do |item|
item.reps.reject { |r| r.raw_path.nil? }.each do |rep|
xml.url do
xml.loc @site.config[:base_url] + rep.path
xml.lastmod item.mtime.to_iso8601_date unless item.mtime.nil?
xml.changefreq item[:changefreq] unless item[:changefreq].nil?
xml.priority item[:priority] unless item[:priority].nil?
end
end
end
end
buffer
end