Skip to content

Commit

Permalink
Set the resource ivar to let meta tags be inferred
Browse files Browse the repository at this point in the history
Solidus sets meta tags if it finds meta_* attributes on the current
controller resource ivar (i.e. names as `controller_name.singularize`).
  • Loading branch information
elia committed Oct 11, 2019
1 parent 30c01de commit 92bc2bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 4 additions & 0 deletions app/controllers/spree/static_content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class Spree::StaticContentController < Spree::StoreController

def show
@page = Spree::Page.by_store(current_store).visible.find_by_slug!(request.path)

# Assign static_content to let solidus recognize it as the current
# controller resource, this is used by meta tags and in other places.
@static_content = @page
end

private
Expand Down
10 changes: 0 additions & 10 deletions app/views/spree/static_content/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
<% if @page.layout.present? and @page.render_layout_as_partial? %>
<%= render :partial => @page.layout %>
<% else %>
<% content_for :head do -%>
<%- if @page.meta_title.present? -%>
<meta name="title" content="<%=@page.meta_title%>">
<%- else -%>
<meta name="title" content="<%=@page.title%>">
<%- end -%>
<meta name="keywords" content="<%=@page.meta_keywords%>">
<meta name="description" content="<%=@page.meta_description%>">
<% end -%>
<% content_for :sidebar do %>
<% if @products && @taxon %>
<%= render :partial => "spree/shared/filters" %>
Expand Down

0 comments on commit 92bc2bd

Please sign in to comment.