diff --git a/app/helpers/better_together/application_helper.rb b/app/helpers/better_together/application_helper.rb index 7470d9d88..9ce38014a 100644 --- a/app/helpers/better_together/application_helper.rb +++ b/app/helpers/better_together/application_helper.rb @@ -97,6 +97,17 @@ def host_community_logo_url rails_storage_proxy_url(attachment) end + # Sets a translated meta description for the current view. Provide the + # translation scope without the `meta.descriptions` prefix. + # + # set_meta_description('communities.show', community_name: @resource.name) + # + # @param scope [String] translation scope under meta.descriptions + # @param options [Hash] interpolation values for the translation + def set_meta_description(scope, **options) + content_for(:meta_description, t("meta.descriptions.#{scope}", **options)) + end + # Builds SEO-friendly meta tags for the current view. Defaults are derived # from translations and fall back to the Open Graph description when set. # rubocop:todo Metrics/MethodLength diff --git a/app/views/better_together/communities/index.html.erb b/app/views/better_together/communities/index.html.erb index f223ec0cc..7c4c301fc 100644 --- a/app/views/better_together/communities/index.html.erb +++ b/app/views/better_together/communities/index.html.erb @@ -2,6 +2,8 @@ <%= resource_class.model_name.human.pluralize %> <% end %> +<% set_meta_description('communities.index', platform_name: host_platform.name) %> +