Created
July 25, 2012 22:28
-
-
Save joelhooks/3179101 to your computer and use it in GitHub Desktop.
Upgrading to Octopress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fill_pages(site, urlset) | |
fill_legacy(urlset) | |
sitemap.add_element(urlset) | |
# File I/O: create sitemap.xml file and write out pretty-printed XML | |
unless File.exists?(site.dest) | |
FileUtils.mkdir_p(site.dest) | |
end | |
file = File.new(File.join(site.dest, SITEMAP_FILE_NAME), "w") | |
formatter = REXML::Formatters::Pretty.new(4) | |
formatter.compact = true | |
formatter.write(sitemap, file) | |
file.close | |
# Keep the sitemap.xml file from being cleaned by Jekyll | |
site.static_files << Jekyll::SitemapFile.new(site, site.dest, "/", SITEMAP_FILE_NAME) | |
end | |
#this is a hack addition to push in my legacy content | |
def fill_legacy(urlset) | |
file = File.new("/Volumes/Gonzales/Users/joel/Code/octopress/plugins/sitemapx.xml") | |
doc = REXML::Document.new(file) | |
root = doc.root | |
root.elements.each do |post| | |
urlset.add_element(post) | |
end | |
end | |
# Create url elements for all the posts and find the date of the latest one | |
# | |
# Returns last_modified_date of latest post | |
def fill_posts(site, urlset) | |
last_modified_date = nil | |
site.posts.each do |post| | |
if !excluded?(post.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment