lib/jekyll-sitemap.rb in jekyll-sitemap-0.6.1 vs lib/jekyll-sitemap.rb in jekyll-sitemap-0.6.2

- old
+ new

@@ -1,8 +1,14 @@ require 'fileutils' module Jekyll + class PageWithoutAFile < Page + def read_yaml(*) + @data ||= {} + end + end + class JekyllSitemap < Jekyll::Generator safe true # Main plugin action, called by Jekyll-core def generate(site) @@ -26,28 +32,28 @@ File.expand_path "sitemap.xml", File.dirname(__FILE__) end # Destination for sitemap.xml file within the site source directory def destination_path - File.expand_path "sitemap.xml", @site.dest + @site.in_dest_dir("sitemap.xml") end # copy sitemap template from source to destination def write FileUtils.mkdir_p File.dirname(destination_path) File.open(destination_path, 'w') { |f| f.write(sitemap_content) } end def sitemap_content - site_map = Page.new(@site, File.dirname(__FILE__), "", "sitemap.xml") + site_map = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", "sitemap.xml") site_map.content = File.read(source_path) site_map.data["layout"] = nil site_map.render(Hash.new, @site.site_payload) site_map.output.gsub(/[\s\n]*\n+/, "\n") end # Checks if a sitemap already exists in the site source def sitemap_exists? - File.exists? File.expand_path "sitemap.xml", @site.source + File.exists? @site.in_source_dir("sitemap.xml") end end end