fix: update URL slugs for cities and weather arts

- Changed URLs to use city slugs instead of IDs
- Updated corresponding URLs for weather arts to use slugs

This change ensures that the URLs are more readable and maintainable
by using slugs rather than numerical IDs. It improves SEO and
user experience when accessing city and weather art pages.
This commit is contained in:
songtianlun 2025-04-08 15:24:29 +08:00
parent 808061c4f3
commit 0ff9ad4ff9

View File

@ -76,9 +76,9 @@ class SubmitToIndexnowWorker
# 城市详情页
City.where("updated_at > ?", recently_updated).find_each do |city|
# City.find_each do |city|
urls << "#{@host}/cities/#{city.id}"
urls << "#{@host}/cities/#{city.slug}"
available_locales.each do |locale|
urls << "#{@host}/#{locale}/cities/#{city.id}"
urls << "#{@host}/#{locale}/cities/#{city.slug}"
end
end
@ -86,9 +86,9 @@ class SubmitToIndexnowWorker
WeatherArt.includes(:city).where("updated_at > ?", recently_updated).find_each do |art|
# WeatherArt.includes(:city).find_each do |art|
if art.image.attached?
urls << "#{@host}/cities/#{art.city.id}/weather_arts/#{art.id}"
urls << "#{@host}/cities/#{art.city.slug}/weather_arts/#{art.slug}"
available_locales.each do |locale|
urls << "#{@host}/#{locale}/cities/#{art.city.id}/weather_arts/#{art.id}"
urls << "#{@host}/#{locale}/cities/#{art.city.slug}/weather_arts/#{art.slug}"
end
end
end