- Implement meta tags in ArtsController, CitiesController, HomeController, and WeatherArtsController for better SEO. - Use translation helpers for titles, descriptions, and keywords to improve internationalization support. - Update default meta tags in ApplicationHelper for consistent site-wide SEO. These changes enhance the search engine visibility of the application by providing relevant meta information across various pages. Utilizing translation for these fields promotes better support for multiple languages, aligning with localization efforts.
53 lines
1.8 KiB
Ruby
53 lines
1.8 KiB
Ruby
module ApplicationHelper
|
|
def weather_art_schema(weather_art)
|
|
{
|
|
"@context": "https://schema.org",
|
|
"@type": "ImageObject",
|
|
"name": "#{weather_art.city.name} Weather Art",
|
|
"description": weather_art.description,
|
|
"datePublished": weather_art.created_at.iso8601,
|
|
"contentUrl": url_for(weather_art.image),
|
|
"author": {
|
|
"@type": "Organization",
|
|
"name": "TodayAIWeather"
|
|
},
|
|
"locationCreated": {
|
|
"@type": "Place",
|
|
"name": weather_art.city.name,
|
|
"address": {
|
|
"@type": "PostalAddress",
|
|
"addressCountry": weather_art.city.country.name
|
|
}
|
|
}
|
|
}.to_json.html_safe if weather_art.image.attached?
|
|
end
|
|
|
|
def current_user_is_admin?
|
|
current_user&.admin?
|
|
end
|
|
|
|
def default_meta_tags
|
|
{
|
|
site: t("site_name", default: "TodayAIWeather"),
|
|
title: t("meta.default.title", default: "TodayAIWeather"),
|
|
description: t("meta.default.description", default: "Experience weather through artistic AI visualization. Daily updated weather art for cities worldwide."),
|
|
keywords: t("meta.default.keywords", default: "AI weather art, weather visualization, city weather, artificial intelligence"),
|
|
separator: "—".html_safe,
|
|
reverse: true,
|
|
og: {
|
|
site_name: t("site_name", default: "TodayAIWeather"),
|
|
type: "website",
|
|
keywords: t("meta.default.og.keywords", default: "ai, ai web, ai art, ai weather, weather art, AI visualization, today ai weather"),
|
|
url: request.original_url
|
|
},
|
|
alternate: available_locales_with_urls
|
|
}
|
|
end
|
|
|
|
def available_locales_with_urls
|
|
I18n.available_locales.each_with_object({}) do |locale, hash|
|
|
hash[locale.to_s] = url_for(locale: locale)
|
|
end
|
|
end
|
|
end
|