today_ai_weather/app/helpers/application_helper.rb
songtianlun a156cc04d1 feat: add default meta tags for SEO
- Implement default_meta_tags method in ApplicationHelper
- Refactor application layout to utilize default_meta_tags

This change improves SEO by centralizing the meta tags configuration. It
ensures consistent metadata across the application while reducing
repetition in the layout files.
2025-04-08 16:48:22 +08:00

52 lines
1.5 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: "TodayAIWeather",
title: "TodayAIWeather",
description: "Experience weather through artistic AI visualization. Daily updated weather art for cities worldwide.",
keywords: "AI weather art, weather visualization, city weather, artificial intelligence",
separator: "—".html_safe,
reverse: true,
og: {
site_name: "TodayAIWeather",
type: "website",
keywords: "ai, ai web, ai art, ai weather, weather art, AI visualization, today ai weather",
url: request.original_url
},
alternate: {
"en" => url_for(locale: "en"),
"zh-CN" => url_for(locale: "zh-CN"),
"ja" => url_for(locale: "ja"),
"ko" => url_for(locale: "ko")
}
}
end
end