Sha256: 4e335f7f3e5f4c9561b3cdb3963c64ed4fcf203c3bb9c01bbc2d9c950fb0269d
Contents?: true
Size: 1.07 KB
Versions: 10
Compression:
Stored size: 1.07 KB
Contents
module Bonsai class Sitemap def self.generate(change_freq = "monthly") index = Bonsai::Page.find("index") template = Tilt::BuilderTemplate.new do lambda { |xml| xml.instruct! xml.urlset(:xmlns=>'http://www.sitemaps.org/schemas/sitemap/0.9') { xml.url { xml.loc(Bonsai.site[:url]) xml.lastmod(index.mtime.utc.strftime("%Y-%m-%d")) xml.changefreq(change_freq) } Bonsai::Page.all.delete_if{|p| p.permalink === "/index/"}.each do |page| xml.url { xml.loc(Bonsai.site[:url] + page.permalink) xml.lastmod(page.mtime.utc.strftime("%Y-%m-%d")) xml.changefreq(change_freq) } end } } end template.render rescue NoMethodError Bonsai.log <<-HELP ! Can't write sitemap. Check that `site.yml` looks something like this: #{File.read(File.dirname(__FILE__) + "/templates/site.yml")} HELP exit end end end
Version data entries
10 entries across 10 versions & 1 rubygems