Sha256: 182ee2f0b8c448c29ba71f152e69e0e2d36bba5b7f4226a61a713ec7fa1005f7

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'builder' # For Tilt

module Alula
  class Sitemap < Generator
    def allow_compressing?
      return :normal
    end
    
    def generate
      urls_callback = ->(context) {
        (context.site.content.posts + context.site.content.pages)
          .reject {|content| content.generator == self }
          .reject {|content| content.metadata.sitemap == false }
          .collect { |content|
            content.languages.collect{|lang| {
              url: content.url(lang),
              lastmod: content.last_modified,
              priority: content.generator.nil? ? 0.5 : 0.3,
            }
          }
        }.flatten
      }
      
      @sitemap_page = Alula::Content::Page.new({
        generator: self,
        urls: urls_callback,
        title: "Sitemap",
        name: "sitemap.xml",
        slug: "sitemap",
        sidebar: false,
        template: self.options.template || "/:locale/:name",
        site: self.site,
        layout: "sitemap",
      })
      self.site.content.pages << @sitemap_page
    end
  end
end

Alula::Generator.register :sitemap, Alula::Sitemap

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alula-0.4.18 lib/alula/generators/sitemap.rb
alula-0.4.17 lib/alula/generators/sitemap.rb