Skip to content

Instantly share code, notes, and snippets.

@rob-mcgrail
Created April 18, 2017 22:23
Show Gist options
  • Save rob-mcgrail/32b2e5e7a36fe10a0a892e4de566f5cc to your computer and use it in GitHub Desktop.
Save rob-mcgrail/32b2e5e7a36fe10a0a892e4de566f5cc to your computer and use it in GitHub Desktop.
config/sitemap.rb
# Set the host name for URL creation
protocol = ENV['PROTOCOL'] || 'http'
SitemapGenerator::Sitemap.default_host = "#{protocol}://#{ENV['HOST']}"
SitemapGenerator::Sitemap.compress = false
SitemapGenerator::Sitemap.create do
add('/topics')
add('/concepts')
add('/?search=true')
Article.published.each do |o|
add o.base_uri, :lastmod => o.updated_at
end
Image.published.each do |o|
add o.base_uri, :lastmod => o.updated_at
end
Video.published.each do |o|
add o.base_uri, :lastmod => o.updated_at
end
Document.published.each do |o|
add o.base_uri, :lastmod => o.updated_at
end
Embed.published.each do |o|
add o.base_uri, :lastmod => o.updated_at
end
self.class.send(:include, TagsHelper)
ActsAsTaggableOn::Tag.all.each do |o|
if o.taggings.first.try(:context)
add tag_path(o, o.taggings.first.context), :lastmod => o.touched_at
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment