Skip to content

Instantly share code, notes, and snippets.

@rbrancher
Created June 22, 2012 18:06
Show Gist options
  • Save rbrancher/2974281 to your computer and use it in GitHub Desktop.
Save rbrancher/2974281 to your computer and use it in GitHub Desktop.
SitemapGenerator::Sitemap.default_host = 'http://leonardofinotti.com'
SitemapGenerator::Sitemap.create do
add root_path, changefreq: 'daily', priority: 1.0
add about_path, changefreq: 'monthly', priority: 0.9
# Projects
Project.published.each do |project|
add project_path(project), priority: 0.8, changefreq: 'weekly', lastmod: project.updated_at
end
# Project by architect
Project.highlight_architects.each do |architect|
add filter_projects_path(key: 'architect', value: architect.to_custom_url), priority: 0.8, changefreq: 'weekly'
end
# Project by country
Project.all.published.distinct(:country).each do |country|
add filter_projects_path(key: 'country', value: country.to_custom_url), priority: 0.7, changefreq: 'weekly'
end
# Project by typology
Project.all.published.distinct(:typology).reject(&:blank?).each do |typology|
add filter_projects_path(key: 'typology', value: typology.to_custom_url), priority: 0.7, changefreq: 'weekly'
end
# Project by build date
Project.all.published.distinct(:build_date_slug).each do |build_date|
add filter_projects_path(key: 'build_date', value: build_date), priority: 0.6, changefreq: 'weekly'
end
# Publication
Publication.published.each do |publication|
add publication_path(publication), priority: 0.5, changefreq: 'weekly', lastmod: publication.updated_at
end
# Publication by author
Publication.highlight_authors.each do |author|
add filter_publications_path(key: 'author', value: author.to_custom_url), priority: 0.6, changefreq: 'weekly'
end
# Publication by media
Publication.all.published.distinct(:media).delete_if{|p| p.blank?}.each do |media|
add filter_publications_path(key: 'media', value: media.to_custom_url), priority: 0.6, changefreq: 'weekly'
end
# Publication by country
Publication.all.published.distinct(:country).each do |country|
add filter_publications_path(key: 'country', value: country.to_custom_url), priority: 0.4, changefreq: 'weekly'
end
# Publication by publication date
Publication.all.published.distinct(:publication_date_slug).each do |publication_date|
add filter_publications_path(key: 'publication_date', value: publication_date), priority: 0.3, changefreq: 'weekly'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment