Class: Jekyll::Make::SitemapGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/jekyll/make/sitemap.rb

Overview

Builds the sitemap as an in-memory page so that it is written by Jekyll's normal output pipeline. Nothing is ever written to the source directory, which would otherwise churn the watcher during jekyll serve and trigger an endless rebuild loop.

Instance Method Summary collapse

Instance Method Details

#generate(site) ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'lib/jekyll/make/sitemap.rb', line 60

def generate(site)
  config = Sitemap.config_for(site)
  return unless config["environments"].include?(Jekyll.env)

  page = Jekyll::PageWithoutAFile.new(site, site.source, "", Sitemap::FILENAME)
  page.content = Sitemap.generate(site, config).join
  page.data["layout"] = nil
  site.pages << page
end