class Jekyll::JekyllSitemap
Constants
- INCLUDED_EXTENSIONS
- MINIFY_REGEX
Matches all whitespace that follows
1. A '>' followed by a newline or 2. A '}' which closes a Liquid tag
We will strip all of this whitespace to minify the template
Public Instance Methods
generate(site)
click to toggle source
Main plugin action, called by Jekyll-core
# File lib/jekyll/jekyll-sitemap.rb, line 9 def generate(site) @site = site @site.pages << sitemap unless file_exists?("sitemap.xml") @site.pages << robots unless file_exists?("robots.txt") end
Private Instance Methods
destination_path(file = "sitemap.xml")
click to toggle source
Destination for sitemap.xml file within the site source directory
# File lib/jekyll/jekyll-sitemap.rb, line 41 def destination_path(file = "sitemap.xml") @site.in_dest_dir(file) end
file_exists?(file_path)
click to toggle source
Checks if a file already exists in the site source
# File lib/jekyll/jekyll-sitemap.rb, line 62 def file_exists?(file_path) if @site.respond_to?(:in_source_dir) File.exist? @site.in_source_dir(file_path) else File.exist? Jekyll.sanitized_path(@site.source, file_path) end end
robots()
click to toggle source
# File lib/jekyll/jekyll-sitemap.rb, line 54 def robots robots = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", "robots.txt") robots.content = File.read(source_path("robots.txt")) robots.data["layout"] = nil robots end
sitemap()
click to toggle source
# File lib/jekyll/jekyll-sitemap.rb, line 45 def sitemap site_map = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", "sitemap.xml") site_map.content = File.read(source_path).gsub(MINIFY_REGEX, "") site_map.data["layout"] = nil site_map.data["static_files"] = static_files.map(&:to_liquid) site_map.data["xsl"] = file_exists?("sitemap.xsl") site_map end
source_path(file = "sitemap.xml")
click to toggle source
Path to sitemap.xml template file
# File lib/jekyll/jekyll-sitemap.rb, line 36 def source_path(file = "sitemap.xml") File.expand_path "../#{file}", File.dirname(__FILE__) end
static_files()
click to toggle source
Array of all non-jekyll site files with an HTML extension
# File lib/jekyll/jekyll-sitemap.rb, line 31 def static_files @site.static_files.select { |file| INCLUDED_EXTENSIONS.include? file.extname } end