Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add seo_robots to the Stores, add robots to the head (#10542)

Piotr Pańkof3e25243c0b0
diff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rb
index 26e76cb633..181f99e234 100644
--- a/core/app/helpers/spree/base_helper.rb
+++ b/core/app/helpers/spree/base_helper.rb
@@ -208,5 +208,12 @@ module Spree
style if style.in? Spree::Image.styles.with_indifferent_access
end
end
+
+ def meta_robots
+ return unless current_store.respond_to?(:seo_robots)
+ return if current_store.seo_robots.blank?
+
+ tag('meta', name: 'robots', content: current_store.seo_robots)
+ end
end
end
diff --git a/core/db/migrate/20201013084504_add_seo_robots_to_spree_stores.rb b/core/db/migrate/20201013084504_add_seo_robots_to_spree_stores.rb
new file mode 100644
index 0000000000..65bb7a1c36
--- /dev/null
+++ b/core/db/migrate/20201013084504_add_seo_robots_to_spree_stores.rb
@@ -0,0 +1,5 @@
+class AddSeoRobotsToSpreeStores < ActiveRecord::Migration[6.0]
+ def change
+ add_column :spree_stores, :seo_robots, :string unless column_exists?(:spree_stores, :seo_robots)
+ end
+end
diff --git a/frontend/app/views/spree/shared/_head.html.erb b/frontend/app/views/spree/shared/_head.html.erb
index 700739c7f9..d4ccf34a0f 100644
--- a/frontend/app/views/spree/shared/_head.html.erb
+++ b/frontend/app/views/spree/shared/_head.html.erb
@@ -2,6 +2,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<%== og_meta_data_tags %>
<%== meta_data_tags %>
+<%== meta_robots %>
<%= canonical_tag(current_store.url) %>
<%= favicon_link_tag 'favicon.ico' %>
<%= stylesheet_link_tag 'spree/frontend/all', media: 'screen', 'data-turbolinks-track': 'reload' %>