fix: update default host in sitemap generator and refresh sitemap on worker
- update default host in sitemap generator - refresh sitemap on worker with new host These changes allow the sitemap to be correctly generated for different environments and to handle the new host correctly, which was the motivation behind this update. No other side effects are expected.
This commit is contained in:
parent
1f47ba59c9
commit
f477f205ab
2
.gitignore
vendored
2
.gitignore
vendored
@ -38,3 +38,5 @@
|
||||
|
||||
/node_modules
|
||||
.idea
|
||||
|
||||
public/sitemap.xml.gz
|
||||
|
@ -2,6 +2,9 @@ class RefreshSitemapWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform
|
||||
host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000"
|
||||
Rails.application.routes.default_url_options[:host] = host
|
||||
SitemapGenerator::Sitemap.default_host = host
|
||||
SitemapGenerator::Sitemap.create do
|
||||
add root_path, changefreq: "daily", priority: 1.0
|
||||
add cities_path, changefreq: "daily", priority: 0.9
|
||||
@ -29,6 +32,7 @@ class RefreshSitemapWorker
|
||||
end
|
||||
|
||||
SitemapGenerator::Sitemap.ping_search_engines if Rails.env.production?
|
||||
Rails.logger.info "Sitemap has been generated successfully"
|
||||
rescue => e
|
||||
Rails.logger.error "Error refreshing sitemap: #{e.message}"
|
||||
end
|
||||
|
@ -1,5 +1,7 @@
|
||||
# Set the host name for URL creation
|
||||
SitemapGenerator::Sitemap.default_host = "https://todayaiweather.com"
|
||||
host = Rails.env.production? ? "https://todayaiweather.com" : "http://127.0.0.1:3000"
|
||||
|
||||
SitemapGenerator::Sitemap.default_host = host
|
||||
|
||||
SitemapGenerator::Sitemap.create do
|
||||
add root_path, changefreq: "daily", priority: 1.0
|
||||
|
Loading…
Reference in New Issue
Block a user