mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 00:23:49 +08:00
FIX: Bad page title for categories view by google crawler
This commit is contained in:
parent
ce0830b23f
commit
ccaf525e8d
|
@ -212,6 +212,10 @@ class ApplicationController < ActionController::Base
|
|||
@guardian ||= Guardian.new(current_user)
|
||||
end
|
||||
|
||||
def current_homepage
|
||||
current_user ? SiteSetting.homepage : SiteSetting.anonymous_homepage
|
||||
end
|
||||
|
||||
def serialize_data(obj, serializer, opts=nil)
|
||||
# If it's an array, apply the serializer as an each_serializer to the elements
|
||||
serializer_opts = {scope: guardian}.merge!(opts || {})
|
||||
|
|
|
@ -24,6 +24,10 @@ class CategoriesController < ApplicationController
|
|||
|
||||
discourse_expires_in 1.minute
|
||||
|
||||
unless current_homepage == 'categories'
|
||||
@title = I18n.t('js.filters.categories.title')
|
||||
end
|
||||
|
||||
store_preloaded("categories_list", MultiJson.dump(CategoryListSerializer.new(@list, scope: guardian)))
|
||||
respond_to do |format|
|
||||
format.html { render }
|
||||
|
|
|
@ -60,7 +60,6 @@ class ListController < ApplicationController
|
|||
list_opts[:no_definitions] = true
|
||||
end
|
||||
|
||||
|
||||
list = TopicQuery.new(user, list_opts).public_send("list_#{filter}")
|
||||
list.more_topics_url = construct_url_with(:next, list_opts)
|
||||
list.prev_topics_url = construct_url_with(:prev, list_opts)
|
||||
|
@ -69,7 +68,7 @@ class ListController < ApplicationController
|
|||
@rss = filter
|
||||
|
||||
# Note the first is the default and we don't add a title
|
||||
if idx > 0 && use_crawler_layout?
|
||||
if (filter.to_s != current_homepage) && use_crawler_layout?
|
||||
filter_title = I18n.t("js.filters.#{filter.to_s}.title")
|
||||
if list_opts[:category]
|
||||
@title = I18n.t('js.filters.with_category', filter: filter_title, category: Category.find(list_opts[:category]).name)
|
||||
|
|
|
@ -23,4 +23,4 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<% content_for :title do %><%= I18n.t('js.filters.categories.title') %><% end %>
|
||||
<% content_for :title do %><%= @title %><% end %>
|
||||
|
|
Loading…
Reference in New Issue
Block a user